[modules/pulseaudio] Refactor callback registration

Make it easier to add/extend callbacks in the future.

fixes #35
This commit is contained in:
Tobi-wan Kenobi 2016-12-17 08:16:10 +01:00
parent cfd1406525
commit 4f7666533c

View file

@ -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.RIGHT_MOUSE, cmd="pavucontrol")
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd="pactl set-{}-mute @DEFAULT_{}@ toggle".format(channel, channel.upper())) events = [
engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, { "type": "mute", "action": "toggle", "button": bumblebee.input.LEFT_MOUSE },
cmd="pactl set-{}-volume @DEFAULT_{}@ +2%".format(channel, channel.upper())) { "type": "volume", "action": "+2%", "button": bumblebee.input.WHEEL_UP },
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, { "type": "volume", "action": "-2%", "button": bumblebee.input.WHEEL_DOWN },
cmd="pactl set-{}-volume @DEFAULT_{}@ -2%".format(channel, channel.upper())) ]
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): def mute(self, value):
self._mute = value self._mute = value