[xmonad] Update volume without polling?

Omari Norman omari at smileystation.com
Wed Dec 30 11:52:42 EST 2009


I like to see my sound volume in my xmobar. Usually I change the volume
using keyboard mappings that I defined in my xmonad.hs. These bindings
call a simple shell script that changes the volume using amixer. The
script then gets the current volume level from amixer and uses echo to
stuff it into a named pipe. xmobar then reads the value using
PipeReader.

This works fine if I change the volume using the xmonad keyboard
binding, but not if I change the volume another way, such as with
alsamixer. Then the volume shown in my status bar is inaccurate. I could
of course simply set up xmobar to periodically read the volume with
amixer at, say, every .1 second or 1 second or whatever. 

What I'm wondering is if there is any way to update the volume without
periodically firing up amixer. I haven't even been able to figure out if
the current alsa volume is available anywhere in the /proc or /sys
directories. There must be some way to do this--for example, if I run
alsamixer and change the volume from outside alsamixer, the bars in
alsamixer instantly update--but could this easily be done with a shell
script too?

Thanks for any help!
Omari



More information about the xmonad mailing list