diff --git a/i3pystatus/backlight.py b/i3pystatus/backlight.py index a24b47a..d1a4401 100644 --- a/i3pystatus/backlight.py +++ b/i3pystatus/backlight.py @@ -1,10 +1,15 @@ from i3pystatus.file import File +from i3pystatus import Module +from i3pystatus.core.command import run_through_shell +import shutil class Backlight(File): """ Screen backlight info + - Reuqire `xbacklight` installed to change the backlight through the scollwheel. + .. rubric:: Available formatters * `{brightness}` — current brightness relative to max_brightness @@ -30,8 +35,18 @@ class Backlight(File): transforms = { "percentage": lambda cdict: round((cdict["brightness"] / cdict["max_brightness"]) * 100), } + on_upscroll = "lighter" + on_downscroll = "darker" def init(self): self.base_path = self.base_path.format(backlight=self.backlight) - + self.has_xbacklight = shutil.which("xbacklight") is not None super().init() + + def lighter(self): + if self.has_xbacklight: + run_through_shell(["xbacklight", "+5"]) + + def darker(self): + if self.has_xbacklight: + run_through_shell(["xbacklight", "-5"])