-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamx_set-touchpad
57 lines (49 loc) · 2.29 KB
/
amx_set-touchpad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ====================================================
# AMX_Manager Copyright(C) 2018 Furkan Türkal
# This program comes with ABSOLUTELY NO WARRANTY; This is free software,
# and you are welcome to redistribute it under certain conditions; See
# file LICENSE, which is part of this source code package, for details.
# ====================================================
#!/bin/bash
ICON_MOUSE=/usr/share/icons/Papirus/64x64/devices/input-mouse.svg
ICON_TOUCHPAD=/usr/share/icons/Papirus/64x64/devices/input-touchpad.svg
# Check for required applications
command -v notify-send >/dev/null 2>&1 || { echo >&2 "AMX_Wallpaper: I require 'notify-send' but it's not installed! Aborting."; exit 1; }
command -v xinput >/dev/null 2>&1 || { echo >&2 "AMX_Wallpaper: I require 'xinput' but it's not installed! Aborting."; exit 1; }
command -v synclient >/dev/null 2>&1 || { echo >&2 "AMX_Wallpaper: I require 'synclient' but it's not installed! Aborting."; exit 1; }
main() {
case "$1" in
toggle)
declare -i ID
ID=`xinput list | grep -Eio '(touchpad|glidepoint)\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
declare -i STATE
STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'`
if [ $STATE -eq 1 ]
then
echo "Touchpad disabled."
synclient TouchpadOff=1
xinput disable $ID
notify-send -a 'AMX_TouchPad' -u low 'Disabled' -i $ICON_TOUCHPAD
else
echo "Touchpad enabled."
xinput enable $ID
synclient TouchpadOff=0
notify-send -a 'AMX_TouchPad' -u low 'Enabled' -i $ICON_TOUCHPAD
fi
;;
auto)
if [ $(ls /dev/input | grep mouse | wc -l) -gt 1 ]; then
synclient TouchpadOff=1
notify-send -a 'AMX_TouchPad' -u low 'Mouse Mod; TouchPad Disabled' -i $ICON_MOUSE
else
synclient TouchpadOff=0
notify-send -a 'AMX_Touchpad' -u low 'TouchPad Mod; Mouse Disabled' -i $ICON_TOUCHPAD
fi
;;
*)
printf "touchpad <command>\n"
printf " toggle \n"
printf " auto \n"
esac
}
main "$@"