From 4c34cd37d4e3ae84de347d6ba5f706ee78ec44a6 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Tue, 1 Nov 2016 08:15:57 +0100 Subject: [PATCH] [modules] Add default click events to various modules * cpu+memory: Open "gnome-system-monitor" * disk: Open nautilus * pulseaudio: Mute/unmute, open "pavucontrol" on right-click, raise/lower volume on mouse wheel up/down --- bumblebee/modules/cpu.py | 3 +++ bumblebee/modules/disk.py | 4 ++-- bumblebee/modules/memory.py | 3 +++ bumblebee/modules/pulseaudio.py | 10 ++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/cpu.py b/bumblebee/modules/cpu.py index cb7cd7f..e99ddd0 100644 --- a/bumblebee/modules/cpu.py +++ b/bumblebee/modules/cpu.py @@ -15,6 +15,9 @@ class Module(bumblebee.module.Module): super(Module, self).__init__(args) self._perc = psutil.cpu_percent(percpu=False) + output.add_callback(module=self.__module__, button=1, + cmd="gnome-system-monitor") + def data(self): self._perc = psutil.cpu_percent(percpu=False) diff --git a/bumblebee/modules/disk.py b/bumblebee/modules/disk.py index eea8e8f..9e8ccf1 100644 --- a/bumblebee/modules/disk.py +++ b/bumblebee/modules/disk.py @@ -16,8 +16,8 @@ class Module(bumblebee.module.Module): super(Module, self).__init__(args) self._path = args[0] if args else "/" - output.add_callback(module=self.__module__, - button=1, cmd="nautilus {instance}") + output.add_callback(module=self.__module__, button=1, + cmd="nautilus {instance}") def data(self): st = os.statvfs(self._path) diff --git a/bumblebee/modules/memory.py b/bumblebee/modules/memory.py index b338211..e3d1bd2 100644 --- a/bumblebee/modules/memory.py +++ b/bumblebee/modules/memory.py @@ -16,6 +16,9 @@ class Module(bumblebee.module.Module): super(Module, self).__init__(args) self._mem = psutil.virtual_memory() + output.add_callback(module=self.__module__, button=1, + cmd="gnome-system-monitor") + def data(self): self._mem = psutil.virtual_memory() diff --git a/bumblebee/modules/pulseaudio.py b/bumblebee/modules/pulseaudio.py index fe4e26a..6d3f13f 100644 --- a/bumblebee/modules/pulseaudio.py +++ b/bumblebee/modules/pulseaudio.py @@ -34,6 +34,16 @@ class Module(bumblebee.module.Module): self._right = 0 self._mono = 0 self._mute = False + channel = "sink" if self._module == "pasink" else "source" + + output.add_callback(module=self.__module__, button=3, + cmd="pavucontrol") + output.add_callback(module=self.__module__, button=1, + cmd="pactl set-{}-mute @DEFAULT_{}@ toggle".format(channel, channel.upper())) + output.add_callback(module=self.__module__, button=4, + cmd="pactl set-{}-volume @DEFAULT_{}@ +2%".format(channel, channel.upper())) + output.add_callback(module=self.__module__, button=5, + cmd="pactl set-{}-volume @DEFAULT_{}@ -2%".format(channel, channel.upper())) def data(self): res = subprocess.check_output(shlex.split("pactl info"))