[ltp] X60s hardware mixer + alsa + python -> notifications

Damjan linux-thinkpad@linux-thinkpad.org
Sat, 26 Jun 2010 03:11:27 +0200


Hi all,
My X60s has a hardware audio volume mixer that's controlled by hardware
buttons above the keyboard (as most of pre *61 Thinkpads afaik).

Since the recent changes in thinkpad-acpi the only way to get 
notifications of changes to the hardware mixer is through the
thinkpad_acpi provided read-only alsa mixer device.

Afaik nothing in current distros supports this, so I've written a small
Python script to get the changes in the hardware mixer.

This simple script just emits a message through the DE notification
system (I'm using this with AwesomeWM) but the Notifier can be
customized any way you need.

The script is pasted here
http://paste.pocoo.org/show/230081/

You might wonder why I need to create a new alsaaudio.Mixer instance all
the time. It's because otherwise the event is not cleared and p.poll()
no longer wait's for new events i.e. returns imidiatelly forever. 
This is either a bug in alsaaudio or alsa (or maybe it's a feature, 
or maybe lack of documentation).

Hope this helps anyone.


Requirements are:

PyAlsaAudio: http://pyalsaaudio.sourceforge.net/

and dbus-python that's ussually installed on distros but you can find it
here too: http://www.freedesktop.org/wiki/Software/DBusBindings

-- 
damjan | дамјан
This is my jabber ID -->         damjan@bagra.net.mk 
 -- not my mail address, it's a Jabber ID --^ :)