Last active
January 24, 2018 08:08
-
-
Save ihipop/cd3956edfbae90aabe20f28188778ee0 to your computer and use it in GitHub Desktop.
热键开关触摸板 touchpad_toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#touchpad_toggle.sh | |
action=${1:-'auto'} | |
#echo $action; | |
declare -i ID | |
ID=`xinput list | grep -Eio '(touchpad|glidepoint)\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'` | |
declare -i STATE | |
if [ "$action" == "off" ];then | |
STATE=1; | |
elif [ "$action" == "on" ];then | |
STATE=0; | |
else | |
STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'` | |
fi; | |
if [ $STATE -eq 1 ];then | |
xinput disable $ID | |
echo "Touchpad disabled." | |
if [ `which notify-send` ]; then | |
notify-send 'Touchpad' 'Disabled' -i /usr/share/icons/Adwaita/48x48/devices/input-touchpad.png | |
fi; | |
else | |
xinput enable $ID; | |
echo "Touchpad enabled." | |
if [ `which notify-send` ]; then | |
notify-send 'Touchpad' 'Enabled' -i /usr/share/icons/Adwaita/48x48/devices/input-touchpad.png | |
fi; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl -L https://gist.githubusercontent.com/ihipop/cd3956edfbae90aabe20f28188778ee0/raw/ -o /usr/local/bin/touchpad_toggle.sh && chmod +x /usr/local/bin/touchpad_toggle.sh touchpad_toggle.sh off touchpad_toggle.sh on touchpad_toggle.sh auto