From c4d96716c05c41a3b18f2326cb588cd19246da5f Mon Sep 17 00:00:00 2001 From: zachir Date: Fri, 12 Aug 2022 04:30:51 -0500 Subject: initial commit --- toggletouchpad | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 toggletouchpad (limited to 'toggletouchpad') 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" -- cgit v1.2.3