-
Notifications
You must be signed in to change notification settings - Fork 4
/
touchpad.sh
executable file
·60 lines (50 loc) · 919 Bytes
/
touchpad.sh
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
58
59
#!/bin/bash
TOUCHPAD="SynPS/2 Synaptics TouchPad"
PROPERTY="Device Enabled"
usage() {
SCRIPT_NAME=`echo $0 | sed -r -e "s/.*\///"`
echo "Usage: $SCRIPT_NAME [on|off]"
echo "With no argument toggles touchpad."
}
set_touchpad() {
xinput --set-prop "$TOUCHPAD" "$PROPERTY" $1
}
toggle_touchpad() {
STATUS=`xinput --list-props "$TOUCHPAD" |
grep "$PROPERTY" |
sed -r -e "s/.*([0-1])$/\1/"`
case $STATUS in
"1") set_touchpad 0
;;
"0") set_touchpad 1
;;
esac
}
print_touchpad_status() {
STATUS=`xinput --list-props "$TOUCHPAD" |
grep "$PROPERTY" |
sed -r -e "s/.*([0-1])$/\1/"`
case $STATUS in
"1") echo "Touchpad is enabled"
;;
"0") echo "Touchpad is disabled."
;;
esac
}
if [[ $# > 1 ]] ; then
usage
exit 1
fi
case $1 in
"on") set_touchpad 1
;;
"off") set_touchpad 0
;;
"status") print_touchpad_status
;;
"") toggle_touchpad
;;
*) usage
exit 1
;;
esac