summaryrefslogtreecommitdiff
path: root/touchpad.sh
blob: 1ef66b94de819a74767c0892c767187431de1b24 (plain)
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
#!/usr/bin/env sh

STATE_FILE="/tmp/touchpad-disabled"

case $1 in
	"enable")
		ACTION="enable"
		;;
	"disable")
		ACTION="disable"
		;;
	"toggle")
		if [ -e "$STATE_FILE" ]; then
			ACTION="enable"
		else
			ACTION="disable"
		fi
		;;
	*)
		echo "Invalid action."
		echo "Usage: $0 enable|disable"
		exit
		;;
esac

if [ "$ACTION" = "enable" ]; then
	rm -f "$STATE_FILE"
else
	touch "$STATE_FILE"
fi

DEVICES=$(xinput list --name-only | grep -i touchpad)

if [ -z "$DEVICES" ]; then
	echo "No touchpad found."
	exit
fi

IFS='
'

for DEVICE in $DEVICES; do
	DISPLAY=:0 xinput "$ACTION" "$DEVICE"
	DISPLAY=:8 xinput "$ACTION" "$DEVICE"
done