To main page

Create signal-based pulseaudio widget for Awesome

December 12, 2017
PulseAudio has dbus support, so at first sight it would be possible to listen to it's signals in widget code. But awesome's dbus API is very limited and accepts only session and system buses, so you can't do it. Some guy created this module but it doesn't work on my machine with Lua 5.1 so I decided to go other way.

I created a helper program that uses libpulse to monitor pulseaudio events and emits dbus signals on a session bus when the sink/source has been muted/unmuted or the volume has been changed. Just run it in background (put /path/to/pulse-volume-monitor dbus & to your .xinitrc or something similar), and now you can use awesome's built-in dbus API:

dbus.request_name("session", "com.ch1p.pvm")
dbus.add_match("session", "interface='com.ch1p.pvm',member='sinkChanged'")
dbus.add_match("session", "interface='com.ch1p.pvm',member='sourceChanged'")
    -- info.member is "sinkChanged" or "sourceChanged"
    -- your code here

mailto: me at ch1p dot com