From 880e78d8955b9977d0dc3a9c27b39c4f303c4e3c Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Tue, 24 Dec 2019 13:59:10 +0100 Subject: [PATCH] [modules/brightness] Add support for wildcards in device Allow users to specify device paths using simple wildcards in the device path. The first matching device will be used. For example: /sys/class/backlight/amdgpu_* fixes #492 --- bumblebee/modules/brightness.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bumblebee/modules/brightness.py b/bumblebee/modules/brightness.py index 0e82351..259afc8 100644 --- a/bumblebee/modules/brightness.py +++ b/bumblebee/modules/brightness.py @@ -13,6 +13,7 @@ import bumblebee.input import bumblebee.output import bumblebee.engine +import glob class Module(bumblebee.engine.Module): def __init__(self, engine, config): @@ -20,7 +21,7 @@ class Module(bumblebee.engine.Module): bumblebee.output.Widget(full_text=self.brightness)) self._brightness = 0 - self._device_path = self.parameter("device_path", "/sys/class/backlight/intel_backlight") + self._device_path = self.find_device(self.parameter("device_path", "/sys/class/backlight/intel_backlight")) step = self.parameter("step", 2) if bumblebee.util.which("light"): @@ -33,6 +34,9 @@ class Module(bumblebee.engine.Module): self.register_cmd(engine, "xbacklight +{}%".format(step), "xbacklight -{}%".format(step)) + def find_device(self, device_path): + return glob.glob(device_path)[0] + def register_cmd(self, engine, upCmd, downCmd): engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, cmd=upCmd) engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, cmd=downCmd)