Skip to content

Instantly share code, notes, and snippets.

@hacst
Created September 21, 2012 19:36
Show Gist options
  • Save hacst/3763438 to your computer and use it in GitHub Desktop.
Save hacst/3763438 to your computer and use it in GitHub Desktop.
Small script for reliably disabling the touchpad over suspend/resume. Tested on Ubuntu 12.04 with a Lenovo X230.
#!/bin/sh
#
# Small script for enabling/disabling the touchpad
# reliably even if it is "hotplugged" with every
# wakeup from standy. Tested on Lenovo X230 with
# Ubuntu 12.04.
#
# Author:
# Stefan Hacker <[email protected]>
#
STATE_FILE=~/.disable_touchpad
case "$1" in
--enable)
echo "Enabling touchpad"
rm -f $STATE_FILE
;;
--disable)
echo "Disabling touchpad"
touch $STATE_FILE
;;
--install)
THIS=`readlink -f $0`
echo "Setting up \"$THIS\" as gnome hotplug handler"
gsettings set org.gnome.settings-daemon.peripherals.input-devices hotplug-command "$THIS"
;;
--remove)
gsettings set org.gnome.settings-daemon.peripherals.input-devices hotplug-command ""
;;
"") ;;
*)
echo "$0 [option]"
echo " --enable Enable touchpads"
echo " --disable Disable touchpads"
echo " --install Install as gnome hotplug handler"
echo " --remove Uninstall gnome hotplug handler"
;;
esac
ENABLE=1
if [ -e $STATE_FILE ];
then
ENABLE=0
fi
# Work on everything with 'TouchPad' in name.
xinput list | \
sed -n 's/.*TouchPad.*id=\([0-9]\+\).*/\1/p' | \
xargs -n1 -IDEVICE xinput set-prop DEVICE "Device Enabled" $ENABLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment