Ubuntu – How to toggle xinput device prop


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?

Best Answer

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"
Related Question