Fix backlight not increasing brightness

This commit is contained in:
Maxi Padulo 2016-01-09 17:39:46 +01:00
parent c591356fc0
commit b132c4d842

View File

@ -41,12 +41,24 @@ class Backlight(File):
def init(self):
self.base_path = self.base_path.format(backlight=self.backlight)
self.has_xbacklight = shutil.which("xbacklight") is not None
# xbacklight expects a percentage as parameter. Calculate the percentage
# for one step (if smaller xbacklight doesn't increases the brightness)
if self.has_xbacklight:
parsefunc = self.components['max_brightness'][0]
maxbfile = self.components['max_brightness'][1]
with open(self.base_path + maxbfile, "r") as f:
max_steps = parsefunc(f.read().strip())
if max_steps:
self.step_size = 100 // max_steps + 1
else:
self.step_size = 5 # default?
super().init()
def lighter(self):
if self.has_xbacklight:
run_through_shell(["xbacklight", "+5"])
run_through_shell(["xbacklight", "-inc", str(self.step_size)])
def darker(self):
if self.has_xbacklight:
run_through_shell(["xbacklight", "-5"])
run_through_shell(["xbacklight", "-dec", str(self.step_size)])