Merge pull request #204 from pandada8/add_scroll_for_backlight

Add scroll support for backlight
This commit is contained in:
enkore 2015-05-19 10:43:53 +02:00
commit ce0504bea0

View File

@ -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"])