[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
This commit is contained in:
parent
42de66c790
commit
880e78d895
1 changed files with 5 additions and 1 deletions
|
@ -13,6 +13,7 @@ import bumblebee.input
|
||||||
import bumblebee.output
|
import bumblebee.output
|
||||||
import bumblebee.engine
|
import bumblebee.engine
|
||||||
|
|
||||||
|
import glob
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
def __init__(self, engine, config):
|
def __init__(self, engine, config):
|
||||||
|
@ -20,7 +21,7 @@ class Module(bumblebee.engine.Module):
|
||||||
bumblebee.output.Widget(full_text=self.brightness))
|
bumblebee.output.Widget(full_text=self.brightness))
|
||||||
self._brightness = 0
|
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)
|
step = self.parameter("step", 2)
|
||||||
|
|
||||||
if bumblebee.util.which("light"):
|
if bumblebee.util.which("light"):
|
||||||
|
@ -33,6 +34,9 @@ class Module(bumblebee.engine.Module):
|
||||||
self.register_cmd(engine, "xbacklight +{}%".format(step),
|
self.register_cmd(engine, "xbacklight +{}%".format(step),
|
||||||
"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):
|
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_UP, cmd=upCmd)
|
||||||
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, cmd=downCmd)
|
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, cmd=downCmd)
|
||||||
|
|
Loading…
Reference in a new issue