#!/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"