Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x)

Muffinman news**REMOVETHIS** at koster.tk
Wed Oct 24 14:55:35 EDT 2012


Hello all,

I'm new to Python (running 2.6.6 but if necessary 3.x should also be
fine). I have a little idea I hope to accomplish with Python. I want to
listen for changes in Alsa sound volume level and base some actions on
that. With the few lines below I can check the current volume level. Can
I extend this so that the script listens for changes in the volume level
and I can base some actions on it? As speed is quite important it's not
an option to poll every second or so for changes, it has to be close to
instantaneous.

If this is not possible with Python, any suggestions on what else are
also welcome of course.

Thanks in advance, Maarten


#############
try
    mixer = alsaaudio.Mixer(Fake, 0)
except alsaaudio.ALSAAudioError:
    sys.stderr.write("No such mixer\n")
    sys.exit(1)

volumes = mixer.getvolume(1)
#############



More information about the Python-list mailing list