1

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?

  • 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 – Artful Aardvark Nov 10 '17 at 16:38
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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.