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 607 times
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
- 104,119