Skip to content

Instantly share code, notes, and snippets.

@ihipop
Last active January 24, 2018 08:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihipop/cd3956edfbae90aabe20f28188778ee0 to your computer and use it in GitHub Desktop.
Save ihipop/cd3956edfbae90aabe20f28188778ee0 to your computer and use it in GitHub Desktop.
热键开关触摸板 touchpad_toggle
#!/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
@ihipop
Copy link
Author

ihipop commented Jan 23, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment