From 25476a257a0a1686a2a7e518ee452ca24be28d65 Mon Sep 17 00:00:00 2001 From: zachir Date: Tue, 21 Feb 2023 15:21:38 -0600 Subject: make toggletouchpad actually work (and silent) --- toggletouchpad | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'toggletouchpad') diff --git a/toggletouchpad b/toggletouchpad index b10d10d..f00dd4f 100755 --- a/toggletouchpad +++ b/toggletouchpad @@ -1,11 +1,10 @@ #!/bin/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" +type synclient >/dev/null 2>&1 && synclient >/dev/null 2>&1 && SYNCLIENT=y || type xinput >/dev/null 2>&1 && 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/"` +[ -n "$XINPUT" ] && DEVICE=`xinput | grep -i touchpad | sed -e 's/.*id\=//' -e 's/\s*\[.*//'` +#echo "$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/'` +#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" -- cgit v1.2.3