From 22419b813f87da4c565f8532185659e6ca212aba Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 24 Nov 2018 10:56:27 +0100 Subject: [PATCH] [modules/brightness] Use 'light' instead of 'xbacklight' If available, use 'light' for setting the background light, as per suggestion of RiadhAmami - thanks! fixes #332 --- bumblebee/modules/brightness.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bumblebee/modules/brightness.py b/bumblebee/modules/brightness.py index 417434e..749f608 100644 --- a/bumblebee/modules/brightness.py +++ b/bumblebee/modules/brightness.py @@ -8,6 +8,7 @@ Parameters: """ +import bumblebee.util import bumblebee.input import bumblebee.output import bumblebee.engine @@ -22,10 +23,16 @@ class Module(bumblebee.engine.Module): self._device_path = self.parameter("device_path", "/sys/class/backlight/intel_backlight") step = self.parameter("step", 2) - engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, - cmd="xbacklight +{}%".format(step)) - engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, - cmd="xbacklight -{}%".format(step)) + if bumblebee.util.which("light"): + engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, + cmd="light -A {}%".format(step)) + engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, + cmd="light -U {}%".format(step)) + else: + engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, + cmd="xbacklight +{}%".format(step)) + engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, + cmd="xbacklight -{}%".format(step)) def brightness(self, widget): if isinstance(self._brightness, float):