Skip to content

Instantly share code, notes, and snippets.

@chwnam
Last active August 1, 2016 02:26
Show Gist options
  • Save chwnam/492b288221d8733f3d6ecd0b8edbc90c to your computer and use it in GitHub Desktop.
Save chwnam/492b288221d8733f3d6ecd0b8edbc90c to your computer and use it in GitHub Desktop.
Detect mouse is attached, and disable touchpad
#!/bin/bash
~/bin/touchpad detect-mouse
detected=$?
if [[ $detected -eq 0 ]]; then
~/bin/touchpad off
else
~/bin/touchpad on
fi
#!/bin/bash
#
# Detect a mouse is attached or not.
# Enable, or disable touchpad.
#
# touchpad on|1|off|0|detect-mouse
PADID=15 # set this pad id, using xinput
if [[ ( "$1" = "on" ) || ( "$1" = "1" ) ]]; then
xinput set-prop $PADID "Device Enabled" 1
elif [[ ( "$1" = "off" ) || ( "$1" = "0" ) ]]; then
xinput set-prop $PADID "Device Enabled" 0
elif [[ ( "$1" = "detect-mouse" ) ]]; then
POINTERS=`/usr/bin/xinput | /bin/grep slave\ *pointer | /usr/bin/wc -l`
if [[ $POINTERS -eq 2 ]]; then
exit 1
else
exit 0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment