Im trying to set a keyboard key to turn off touchpad. i noticed How do I disable a touchpad using the command line?, however all the commands feature a separate function to turn the touchpad on vs. off. How can you set up a single command to turn the touchpad on if it's off or off if it's on?
Asked
Active
Viewed 585 times
1
-
In my opinion, the link you have included in your question contains the answer. You want to be able to use same set of key(s) to toggle your touchpad on or off, right? – Manish Kumar Bisht Nov 10 '17 at 15:44
-
no just one key. so i need a single command. its the disable / enable touchpad button. @ManishKumarBisht – Edgy1 Nov 10 '17 at 16:38
1 Answers
2
This script should do it. Save it as ~/bin/toggle_touchpad.sh
, change the value of the touchpad
variable to whatever your touchpad is called (see xinput list
) and then map the script to your desired keyboard shortcut. Remember to make the script executable with chmod a+x ~/bin/toggle_touchpad.sh
.
#!/bin/bash
## Change this value to whatever your touchpad is called
touchpad='SynPS/2 Synaptics TouchPad'
status=$(xinput list-props "$touchpad" | grep "Device Enabled" | gawk '{print $NF}');
if (( $status==1 )); then
xinput -set-int-prop "$touchpad" "Device Enabled" 8 0
else
xinput -set-int-prop "$touchpad" "Device Enabled" 8 1
fi

terdon
- 100,812