
Omari Norman
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. [...]
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?
Alsamixer reads /dev/snd/controlC0 (for the first card). It speaks a binary protocol, definitely not for shell scripts. And the Haskell binding for ALSA lacks the control interface, AFAICS. But you can write a very simple C program to continuously print the volume changes on a given card, and use that from your script. Or even better, extend the Haskell ALSA library to provide the needed functionality, and add it to xmobar. :) -- Regards, Feri.