summaryrefslogtreecommitdiff
path: root/toggletouchpad
blob: f00dd4f5376b1fc7461049a1dd297f286ca54a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
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"
[ -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"