I can disable a device like this:

xinput set-prop 13 "Device Enabled" 0

But I want to actually set a custom shortcut that toggles this between 0\1. My bash skills are kinda rusty, so how can I do this? There's no get-prop command, I got this far:

xinput list-props 13 | grep "Device Enabled"

Which correctly prints out

Device Enabled (135):   1

But I don't know what to do next. Help?

2 Answers 2


Toggle xinput device on or off with following bash script.


state=$(xinput list-props "$device" | grep "Device Enabled" | grep -o "[01]$")

if [ $state == '1' ];then
  xinput --disable "$device"
  xinput --enable "$device"

I made this one-liner from Jason YiZhang Chen's answer. It's handy if you just need a command to put in a keyboard shortcut or startup job. It exploits the fact that you can also set properties of devices by name, and that the name of the touchpad won't change.

To get the device name:

$ xinput | grep Touchpad
⎜   ↳ ETPS/2 Elantech Touchpad                  id=18   [slave  pointer  (2)]

So my device is called ETPS/2 Elantech Touchpad. I hardcode that into this one-liner:

[ "$(xinput list-props 'ETPS/2 Elantech Touchpad' | grep 'Device Enabled' | grep -o '[01]$')" == "1" ] && xinput --disable 'ETPS/2 Elantech Touchpad' || xinput --enable 'ETPS/2 Elantech Touchpad'
  • 'xinput set-prop 18 "Device Enabled" $((1-$(xinput list-props 18 | grep "Device Enabled" | grep -o "[01]$")))' Jan 14, 2021 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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