Been playing around with this and came up with a toggle on/off script.
The script will toggle my "Nostromo SpeedPad2" gaming keyboard on/off.
Could adapt it for your device.
eg this is my xinput...
Code:
glen@Raring:~$ xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ DEXIN Tt eSPORTS BLACK Gaming mouse id=11 [slave pointer (2)]
⎜ ↳ DEXIN Tt eSPORTS BLACK Gaming mouse id=12 [slave pointer (2)]
⎜ ↳ Honey Bee Nostromo SpeedPad2 id=9 [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)]
↳ Power Button id=7 [slave keyboard (3)]
↳ Logitech Logitech USB Headset id=10 [slave keyboard (3)]
↳ Ideazon Zboard id=14 [slave keyboard (3)]
↳ Ideazon Zboard id=13 [slave keyboard (3)]
↳ Honey Bee Nostromo SpeedPad2 id=8 [slave keyboard (3)]
....and from that output derived this toggle script...
Code:
#!/bin/bash
# Script to toggle a usb device on/off
# This works to disable my Nostromo SpeedPad2 that I only use for gaming.
# Need to adapt deviceid variable to use your device from the output of "xinput --list"
deviceid=$(xinput --list | awk '/Virtual core keyboard/{y=1;next}y' | grep -m1 "Nostromo" | awk '{print $6}' | tr -d 'id=')
devicestate=$(xinput --list-props $deviceid | awk '/Device Enabled/ {print $4}') # 0=disabled 1=enabled
devicename=$(xinput --list --name-only $deviceid)
if [ $devicestate = 0 ]; then
xinput --enable $deviceid
notify-send -i keyboard "Enabled" "$devicename"
else
xinput --disable $deviceid
notify-send -i keyboard "Disabled" "$devicename"
fi
If you need help to make the script work for your device
post the results from...
Bookmarks