summaryrefslogtreecommitdiff
path: root/toggletouchpad
blob: 553cf6072f87a133b442a9d9277f39a9d1f47612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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"