Add xbacklight support
This commit is contained in:
parent
22b5abf899
commit
3c01f85455
@ -1,4 +1,6 @@
|
|||||||
from i3pystatus.file import File
|
from i3pystatus.file import File
|
||||||
|
import shutils
|
||||||
|
import subprocesss
|
||||||
|
|
||||||
|
|
||||||
class Backlight(File):
|
class Backlight(File):
|
||||||
@ -30,8 +32,18 @@ class Backlight(File):
|
|||||||
transforms = {
|
transforms = {
|
||||||
"percentage": lambda cdict: (cdict["brightness"] / cdict["max_brightness"]) * 100,
|
"percentage": lambda cdict: (cdict["brightness"] / cdict["max_brightness"]) * 100,
|
||||||
}
|
}
|
||||||
|
on_upscroll = "lighter"
|
||||||
|
on_downscroll = "darker"
|
||||||
|
|
||||||
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.has_xbacklight = shutils.which("xbacklight") is not None
|
||||||
super().init()
|
super().init()
|
||||||
|
|
||||||
|
def lighter(self):
|
||||||
|
if self.has_xbacklight:
|
||||||
|
subprocess.Popen(["backlight", '+5'])
|
||||||
|
|
||||||
|
def darker(self):
|
||||||
|
if self.has_xbacklight:
|
||||||
|
subprocess.Popen(["backlight", '-5'])
|
||||||
|
Loading…
Reference in New Issue
Block a user