Last active
August 1, 2016 02:26
-
-
Save chwnam/492b288221d8733f3d6ecd0b8edbc90c to your computer and use it in GitHub Desktop.
Detect mouse is attached, and disable touchpad
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 | |
| ~/bin/touchpad detect-mouse | |
| detected=$? | |
| if [[ $detected -eq 0 ]]; then | |
| ~/bin/touchpad off | |
| else | |
| ~/bin/touchpad on | |
| fi |
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 | |
| # | |
| # 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