NSLU2 Tools: keyevent
Purpose'keyevent' is a little tool derived from evtest.c to report keys being pressed or released on a selectable hardware device. It uses the Linux kernel's event interface, so be sure to load the evdev kernel module (modprobe evdev) before using keyevent.
An example for the tool's output:
Double-clicking with the right button of a mouse:
> src/keyevent 09da 0006 Looking for device PID=09da VID=0006 Found event device #2 RightBtn pressed RightBtn released RightBtn pressed repeat RightBtn released
For my Trust USB Sound Card pressing the MUTE button looks like:
> src/keyevent 145f 0090 Looking for device PID=145f VID=0090 Found event device #2 Mute pressed Mute released
Ok, that's nice but not so useful without any application interpreting the output. The example below implements a shell script to control the Music Player Daemon (MPD) using just the MUTE button on the USB sound card mentioned above.
#!/bin/sh MPD_HOST=localhost MPD_PORT=6600 VID=145f PID=0090 cmd_repeat="echo -e 'repeat 1\nclose' | nc $MPD_HOST $MPD_PORT > /dev/null" cmd_playing="echo -e 'status\nclose' | nc $MPD_HOST $MPD_PORT | grep state: | grep -q play" cmd_next="echo -e 'next\nclose' | nc $MPD_HOST $MPD_PORT > /dev/null" cmd_stop="echo -e 'stop\nprevious\nclose' | nc $MPD_HOST $MPD_PORT > /dev/null" cmd_play="echo -e 'play\nclose' | nc $MPD_HOST $MPD_PORT > /dev/null" eval $cmd_repeat keyevent $VID $PID 5000 1000 1000 10000 | \ ( while : do read key state rep echo $key $state $rep if [ "$state" = "pressed" ] then if [ "$rep" = "double" ] then if eval $cmd_playing then echo "stopping" eval $cmd_stop fi else # single key press if eval $cmd_playing then echo "next song" eval $cmd_next else echo "starting" eval $cmd_play fi fi fi done )
Pressing the button once turns the player on ("PLAY") or, if it is already playing, skips to the next song in the playlist ("NEXT"). Pressing the button twice within 1 second stops the player ("STOP").
|keyevent 0.3 Source Code|
|keyevent 0.1 Source Code (outdated)|
|keyevent 0.1 BitBake Package|
The packages are also available on my SlugOS/BE 3.10b feed. Follow these instructions (as root):
- Log into your NSLU2 and add the DevBase feed:
# echo "src/gz devbase http://feed.devbase.at/slugos-3.10" > /etc/ipkg/01-devbase-feed.conf
- Update the package database:
# ipkg update
- Install some package:
# ipkg install some-package
Posted by João on Saturday, 08.23.2008 @ 05:24AM
If you have a little moment, I will appreciate any hint or sugestion from you
Posted by alan on Tuesday, 01.13.2009 @ 05:50AM
Great setup - I have a very similar home setup with my NSLU2, but haven't yet got the 5.1 sound working on my Trust USB sound card (same as yours). Have you got it working?
a few months ago I moved my sound card from the NSLU2 to the QNAP TS-109 II. However I can confirm the following:
- On the slug 2.0 was working fine.
- Also on the slug I used dmix to create 2 independent virtual 2.0 sound cards where one was connected to the stereo and the other one to the mini-speaker (shown in my pictures). That also worked fine but create ~15% additional CPU usage by dmix. So after a year I bought a small dedicated CMedia sound card for the speaker.
- I just tried "speaker-test" on the TS109 and it works fine in a 5.1 setup. I did not check whether there was an actual signal on the respective outputs though. This is without any /etc/asound.conf or ~/.asoundrc file, the ALSA lib and utils are version 1.0.17, kernel is 2.6.27.
Posted by Coleman on Friday, 02.13.2009 @ 07:06AM
thanks again for your hard work, good effort :)
The author does not take any responsibility for problems and damage arising by installing or using this software, use it at your own risk.