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?

Toggle xinput device on or off with following bash script.

#!/bin/bash

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

if [ $state == '1' ];then
  xinput --disable "$device"
else
  xinput --enable "$device"
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.