[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
This commit is contained in:
Tobias Witek 2016-11-01 08:15:57 +01:00
parent fca3171556
commit 4c34cd37d4
4 changed files with 18 additions and 2 deletions

View file

@ -15,6 +15,9 @@ class Module(bumblebee.module.Module):
super(Module, self).__init__(args) super(Module, self).__init__(args)
self._perc = psutil.cpu_percent(percpu=False) self._perc = psutil.cpu_percent(percpu=False)
output.add_callback(module=self.__module__, button=1,
cmd="gnome-system-monitor")
def data(self): def data(self):
self._perc = psutil.cpu_percent(percpu=False) self._perc = psutil.cpu_percent(percpu=False)

View file

@ -16,8 +16,8 @@ class Module(bumblebee.module.Module):
super(Module, self).__init__(args) super(Module, self).__init__(args)
self._path = args[0] if args else "/" self._path = args[0] if args else "/"
output.add_callback(module=self.__module__, output.add_callback(module=self.__module__, button=1,
button=1, cmd="nautilus {instance}") cmd="nautilus {instance}")
def data(self): def data(self):
st = os.statvfs(self._path) st = os.statvfs(self._path)

View file

@ -16,6 +16,9 @@ class Module(bumblebee.module.Module):
super(Module, self).__init__(args) super(Module, self).__init__(args)
self._mem = psutil.virtual_memory() self._mem = psutil.virtual_memory()
output.add_callback(module=self.__module__, button=1,
cmd="gnome-system-monitor")
def data(self): def data(self):
self._mem = psutil.virtual_memory() self._mem = psutil.virtual_memory()

View file

@ -34,6 +34,16 @@ class Module(bumblebee.module.Module):
self._right = 0 self._right = 0
self._mono = 0 self._mono = 0
self._mute = False 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): def data(self):
res = subprocess.check_output(shlex.split("pactl info")) res = subprocess.check_output(shlex.split("pactl info"))