Created
September 20, 2015 17:01
-
-
Save arax/8dcf5de44bc71715439c to your computer and use it in GitHub Desktop.
Toggle the touchpad (on/off)
This file contains hidden or 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 | |
########################################################################### | |
## toggleTouchpad.sh | |
## | |
## Toggle the touchpad on/off. | |
########################################################################### | |
# Get the id number of the touchpad. | |
tp_id=`xinput list | grep -i touchpad | awk '{ print $6 }' | sed 's/id=//'` | |
# Find out whether the touchpad is enabled or not. | |
tp_enabled=`xinput list-props $tp_id | grep Device\ Enabled | awk '{ print $4 }'` | |
if [ $tp_enabled = 0 ]; then | |
# The touchpad is currently disabled, so turn it on. | |
xinput set-prop $tp_id "Device Enabled" 1 | |
echo "Touchpad now on." | |
elif [ $tp_enabled = 1 ]; then | |
# The touchpad is currently enabled, so turn it off. | |
xinput set-prop $tp_id "Device Enabled" 0 | |
echo "Touchpad now off." | |
else | |
# Something went wrong ... | |
echo "toggleTouchpad: Could not get touchpad status from xinput." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment