|
Targus Wireless Presenter and Emacs Volume Control |
Finding wireless input devices (for controlling the stereo) that are
1) not too ugly and
2) works reliably and
3) has a range over a few meters
isn’t trivial. I’ve experimented with a few thingamabobs, and one device I’m pretty satisfied with is the Targus … er… I can’t find any model name here. AMP02EU? Anyway, it’s a “wireless presenter” (with a laser pointer, so I could entertain a cat if I had a cat, but I don’t *sob*), so, of course, it isn’t really geared towards music playing. But since, these days, all input devices show up as input devices in Linux, you can use it for whatever you want, with a bit of configuration.
The first thing to do is to put the following in /etc/udev/rules.d/90-itron.rules. It has to be “late” in the udev chain so that other rules don’t overwrite the name we want.
KERNEL==”event*”, BUS==”usb”, SYSFS{idVendor}==”195d”, SYSFS{idProduct}==”7777″, MODE=”0666″, NAME=”input/itron%n”
I chose the name “itron” since that’s what lsusb claims that this device is:
rocket-sam:/etc# lsusb
Bus 002 Device 018: ID 195d:7777 Itron Technology iONE Scorpius wireless keyboard
Now that we know where the device will show up (i.e., /dev/input/itron*), we can route events to the commands we want to execute. I googled around for a while before deciding to use evrouter, which gives us pretty simple access to all events.
“Itron Powerful Receiver” “” any rel/1/1 “Shell/emacsclient –server-file=rocket-sam –eval ‘(jukebox-decrease-volume)'”
“Itron Powerful Receiver” “” any rel/1/-1 “Shell/emacsclient –server-file=rocket-sam –eval ‘(jukebox-increase-volume)'”
“Itron Powerful Receiver” “” any key/272 “Shell/emacsclient –server-file=rocket-sam –eval ‘(jukebox-pause)'”
“Itron Powerful Receiver” “” any key/104 “Shell/lights 0”
“Itron Powerful Receiver” “” any key/109 “Shell/lights 1”
The first string is the name of the device (yes, that’s what it calls itself. How masterful). “rel” is the mouse. “key” is, er, a key.
So this decreases volume when the mouse goes down, increases when the mouse goes up, pauses the music when I press the big button down, and switches the lights in the room off/on on two of the other buttons.
Which still leaves me with more unused buttons, but I haven’t found a use for them yet.
Then start the event routing in a startup script like so:
$ rm -f /tmp/.evrouter\:0.0
$ /usr/local/src/evrouter-0.4/src/evrouter -f /dev/input/itron*
(The first “rm” is needed because evrouter doesn’t seem to clean up after itself always…)
The only minor problem I now have is that although evrouter picks up the events, they still get passed on to X. So when I increase the volume, the mouse cursor goes upwards. I haven’t bothered trying to investigate how to make X ignore certain input units, but if anyone has a pointer to a conf example, please leave a note in the comments.