diff --git a/bumblebee/modules/pulseaudio.py b/bumblebee/modules/pulseaudio.py index 2252b26..7578438 100644 --- a/bumblebee/modules/pulseaudio.py +++ b/bumblebee/modules/pulseaudio.py @@ -33,12 +33,17 @@ class Module(bumblebee.engine.Module): ] engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd="pavucontrol") - engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, - cmd="pactl set-{}-mute @DEFAULT_{}@ toggle".format(channel, channel.upper())) - engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, - cmd="pactl set-{}-volume @DEFAULT_{}@ +2%".format(channel, channel.upper())) - engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, - cmd="pactl set-{}-volume @DEFAULT_{}@ -2%".format(channel, channel.upper())) + + events = [ + { "type": "mute", "action": "toggle", "button": bumblebee.input.LEFT_MOUSE }, + { "type": "volume", "action": "+2%", "button": bumblebee.input.WHEEL_UP }, + { "type": "volume", "action": "-2%", "button": bumblebee.input.WHEEL_DOWN }, + ] + + for event in events: + engine.input.register_callback(self, button=event["button"], + cmd="pactl set-{}-{} @DEFAULT_{}@ {}".format(channel, event["type"], + channel.upper(), event["action"])) def mute(self, value): self._mute = value