I've written a small program that toggles whether a device is enabled, mostly to run from a hotkey to enable/disable the touchpad since my hands always hit it while typing.
I have it using notify-send
to create a dialog box, however all I can currently do is say
device $1 has been enabled
The output of xinput list looks like :
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Atmel Atmel maXTouch Digitizer id=10 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech Touchpad id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ USB2.0 HD UVC WebCam id=11 [slave keyboard (3)]
↳ Asus WMI hotkeys id=12 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
Is there any easy way to reliably get ETPS/2 Elantech Touchpad
or USB2.0 HD UVC WebCam
? A regex won't correctly match unless I look for the ↳ character, something in between, then multiple spaces, but is that a valid character for a regex?
Edit : The script is simple so I've included it, it's called with a device number (would be cool if I could also toggle_device touchpad
but that's a later problem)
#!/bin/bash
DEVICE_ENABLED=`xinput list-props $1 | grep "Enabled" | awk '{print $NF}'`
if [ "$DEVICE_ENABLED" == "1" ] #disable if it's enabled
then
xinput set-prop $1 "Device Enabled" 0
notify-send "Device $1 has been disabled"
else
xinput set-prop $1 "Device Enabled" 1
notify-send "Device $1 has been enabled"
fi