Glob expansion in backlight
Using default settings ("*"), this will match any device found in backlight. Fix #442.
This commit is contained in:
parent
884e85aab4
commit
7a081f4dd3
@ -1,6 +1,7 @@
|
|||||||
from i3pystatus.file import File
|
from i3pystatus.file import File
|
||||||
from i3pystatus import Module
|
from i3pystatus import Module
|
||||||
from i3pystatus.core.command import run_through_shell
|
from i3pystatus.core.command import run_through_shell
|
||||||
|
import glob
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
@ -19,12 +20,14 @@ class Backlight(File):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
("format", "format string, formatters: brightness, max_brightness, percentage"),
|
("format", "format string, formatters: brightness, max_brightness, percentage"),
|
||||||
("backlight", "backlight, see `/sys/class/backlight/`"),
|
("backlight",
|
||||||
|
"backlight, see `/sys/class/backlight/`. Supports glob expansion, i.e. `*` matches anything. "
|
||||||
|
"If it matches more than one filename, selects the first one in alphabetical order"),
|
||||||
"color",
|
"color",
|
||||||
)
|
)
|
||||||
required = ()
|
required = ()
|
||||||
|
|
||||||
backlight = "acpi_video0"
|
backlight = "*"
|
||||||
format = "{brightness}/{max_brightness}"
|
format = "{brightness}/{max_brightness}"
|
||||||
|
|
||||||
base_path = "/sys/class/backlight/{backlight}/"
|
base_path = "/sys/class/backlight/{backlight}/"
|
||||||
@ -40,6 +43,7 @@ class Backlight(File):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.base_path = self.base_path.format(backlight=self.backlight)
|
self.base_path = self.base_path.format(backlight=self.backlight)
|
||||||
|
self.base_path = sorted(glob.glob(self.base_path))[0]
|
||||||
self.has_xbacklight = shutil.which("xbacklight") is not None
|
self.has_xbacklight = shutil.which("xbacklight") is not None
|
||||||
|
|
||||||
# xbacklight expects a percentage as parameter. Calculate the percentage
|
# xbacklight expects a percentage as parameter. Calculate the percentage
|
||||||
|
Loading…
Reference in New Issue
Block a user