From ba466d51797f44734b04d171aab253b58b46b9c7 Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Wed, 9 Nov 2016 19:37:09 +0100 Subject: [PATCH] [modules/brightness] Add callbacks for increasing/decreasing brightness Use xbacklight to increase or decrease brightness when the user uses the mouse wheel over the brightness widget. --- bumblebee/modules/brightness.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bumblebee/modules/brightness.py b/bumblebee/modules/brightness.py index d91e55c..114c11e 100644 --- a/bumblebee/modules/brightness.py +++ b/bumblebee/modules/brightness.py @@ -3,6 +3,11 @@ import bumblebee.module def description(): return "Displays brightness percentage" +def parameters(): + return [ + "brightness.step: Steps (in percent) to increase/decrease brightness on scroll (defaults to 2)", + ] + class Module(bumblebee.module.Module): def __init__(self, output, config, alias): super(Module, self).__init__(output, config, alias) @@ -10,6 +15,11 @@ class Module(bumblebee.module.Module): self._max = 0 self._percent = 0 + step = self._config.parameter("step", 2) + + output.add_callback(module=self.instance(), button=4, cmd="xbacklight +{}%".format(step)) + output.add_callback(module=self.instance(), button=5, cmd="xbacklight -{}%".format(step)) + def widgets(self): with open("/sys/class/backlight/intel_backlight/brightness") as f: self._brightness = int(f.read()) @@ -20,3 +30,4 @@ class Module(bumblebee.module.Module): return bumblebee.output.Widget(self, "{:02d}%".format(self._percent)) +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4