Skip to content

Instantly share code, notes, and snippets.

@arax
Created September 20, 2015 17:01
Show Gist options
  • Save arax/8dcf5de44bc71715439c to your computer and use it in GitHub Desktop.
Save arax/8dcf5de44bc71715439c to your computer and use it in GitHub Desktop.
Toggle the touchpad (on/off)
#!/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