[modules/pulseaudio] Refactor callback registration
Make it easier to add/extend callbacks in the future. fixes #35
This commit is contained in:
parent
cfd1406525
commit
4f7666533c
1 changed files with 11 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue