Created
September 10, 2013 12:58
-
-
Save coderiot/6509030 to your computer and use it in GitHub Desktop.
bash script toggle touchpad with xinput.
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 | |
| id=$(xinput | grep TouchPad | grep -E -o "id=[[:digit:]]+" | grep -E -o "[[:digit:]]+") | |
| if [ "$id" = "" ] | |
| then | |
| echo "no touchpad found." | |
| exit 0 | |
| fi | |
| status=$(xinput list-props 10 | grep "Device Enabled" | cut -f3) | |
| if [ $status -eq 0 ] | |
| then | |
| xinput set-prop $id "Device Enabled" 1 | |
| echo "enabling device $id" | |
| else | |
| xinput set-prop $id "Device Enabled" 0 | |
| echo "disabling device $id" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
Thanks for creating this. However it appears to me that you have hardcoded your device number (10), so if anyone's touchpad is in any other number this will not work. Additionally (at least in my case), xinput will call them Touchpad and not TouchPad. Lastly, more than one pointing device under that category can be present, and your script will crash if it is the case, as it will try to pass 2 IDs separated by a new line whenever we use the ID (in your case it may not, as it is hardcoded).
The following modification will use the IDs captured by grep and loop through them to enable/disable all of them (also uses the string "Touchpad" instead of "TouchPad", but that is just for my own setup.
I am a noob and don't know how to submit merge requests so I will just paste it here:
Thanks again, this helped me manage my touchpad in i3wm. For anyone who might be here for the same reason, save this script as, for example, touchpad-toggle.sh, and add this line to your i3 config file:
bindsym XF86TouchpadToggle exec /home/path/to/configfile/touchpad-toggle.sh