Skip to content

Instantly share code, notes, and snippets.

@ericponce
Last active January 29, 2018 18:16
Show Gist options
  • Save ericponce/8d52f54a224c97612e9e6c0905968f9f to your computer and use it in GitHub Desktop.
Save ericponce/8d52f54a224c97612e9e6c0905968f9f to your computer and use it in GitHub Desktop.
acpid script/trigger for disabling mouse input in tablet mode
# Event file for tablet mode conversions
# Should be placed in /etc/acpi/events
event=tabletmode
action=/etc/acpi/tablet-mode.sh %e
#!/bin/sh
# acpid handler for Lenovo X1 Yoga (2nd Gen) tablet mode
# When the screen is completely flipped, the following trigger occurs
# video/tabletmode TBLT 0000008A 00000001
# this file should be symlink'd into the correct place as described by the event file
# to force acpid to reload rules
# ps -ax | grep -i acpid
# kill -SIGHUP <pid>
# very useful link: https://askubuntu.com/questions/980997/how-do-i-disable-the-touchpad-when-the-lid-is-twisted-or-closed
TRACKPOINT="TPPS/2 IBM TrackPoint"
TOUCHPAD="SynPS/2 Synaptics TouchPad"
LANG=C # Ensure stable parsing
export DISPLAY="$(w | awk 'NF > 7 && $2 ~ /tty[0-9]+/ {print $3; exit}' 2>/dev/null)" # Get and export the current user's $DISPAY
export XAUTHORITY="/home/$(w | awk 'NF > 7 && $2 ~ /tty[0-9]+/ {print $1; exit}' 2>/dev/null)/.Xauthority" # Get and export the currentuser's $XAUTHORITY
case "$2" in
TBLT)
case "$4" in
00000000)
xinput enable "$TRACKPOINT"
xinput enable "$TOUCHPAD"
;;
00000001)
xinput disable "$TRACKPOINT"
xinput disable "$TOUCHPAD"
;;
esac
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment