summaryrefslogtreecommitdiff
path: root/toggletouchpad
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2022-08-12 04:30:51 -0500
committerzachir <zachir@librem.one>2022-08-12 04:30:51 -0500
commitc4d96716c05c41a3b18f2326cb588cd19246da5f (patch)
treeaa6b16c2e89ee63d37eb05e38577ec0b0bddea59 /toggletouchpad
initial commit
Diffstat (limited to 'toggletouchpad')
-rwxr-xr-xtoggletouchpad14
1 files changed, 14 insertions, 0 deletions
diff --git a/toggletouchpad b/toggletouchpad
new file mode 100755
index 0000000..553cf60
--- /dev/null
+++ b/toggletouchpad
@@ -0,0 +1,14 @@
+#!/sbin/sh
+CONTROLLER=`which synclient`
+[ -x "$CONTROLLER" ] && SYNCLIENT=y || CONTROLLER=`which xinput`
+[ ! -x "$CONTROLLER" ] && XINPUT=y || echo "This script requires X11"
+[ -n "$SYNCLIENT" ] && TOUCHPADSTATE=`synclient | grep "TouchpadOff" | sed -e "s/^\s*TouchpadOff\s*=\s*//" -e "s/1/y/" -e "s/0/n/"` || unset SYNCLIENT
+[ -n "$XINPUT" ] && DEVICE=`echo $($CONTROLLER) | grep -i touchpad | sed -e 's/.*id\=//' -e 's/\s*\[.*//'` || unset DEVICE
+[ -n "$XINPUT" -a -n "$DEVICE" ] && TOUCHPADSTATE=`xinput list-props $DEVICE | grep -i 'device enabled' | sed -e 's/.*:\s*//' -e 's/0/y/' -e 's/1/n/'` || unset XINPUT
+echo "$TOUCHPADSTATE $SYNCLIENT $XINPUT"
+[ -z "$SYNCLIENT" -a -z "$XINPUT" -o -z "$TOUCHPADSTATE" ] && echo "Couldn't use either synclient or xinput" && exit
+[ ! "$TOUCHPADSTATE" = "y" ] || unset TOUCHPADSTATE
+[ -z "$TOUCHPADSTATE" -a -n "$SYNCLIENT" ] && synclient "touchpadoff=0" && notify-send "Enabled Touchpad"
+[ -n "$TOUCHPADSTATE" -a -n "$SYNCLIENT" ] && synclient "touchpadoff=1" && notify-send "Disabled Touchpad"
+[ -z "$TOUCHPADSTATE" -a -n "$XINPUT" ] && xinput enable "$DEVICE" && notify-send "Enabled Touchpad"
+[ -n "$TOUCHPADSTATE" -a -n "$XINPUT" ] && xinput disable "$DEVICE" && notify-send "Disabled Touchpad"