From e33ea82dc52ad66d6e191e75a07fcb03375682a9 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Sun, 29 Oct 2017 14:04:13 +0100 Subject: max brightness is > 255 on X250 --- tp-key-handler | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tp-key-handler b/tp-key-handler index dd13f4c..3c3856e 100755 --- a/tp-key-handler +++ b/tp-key-handler @@ -44,12 +44,16 @@ class KeyhandlerDBUSService(dbus.service.Object): with open("/sys/class/backlight/intel_backlight/brightness", "r") as f: return int(f.readline().strip()) + def _getMaxBacklight(self): + with open("/sys/class/backlight/intel_backlight/max_brightness", "r") as f: + return int(f.readline().strip()) + def _setBacklight(self, value): with open("/sys/class/backlight/intel_backlight/brightness", "w") as f: f.write(str(value)) def _showBacklightState(self): - state = self._getBacklight() * 100 / 255 + state = self._getBacklight() * 100 / self._getMaxBacklight() self.bnotice.set_hint_int32("value", int(state)) self.bnotice.set_hint_string("synchronous", "brightness") self.bnotice.show() @@ -135,8 +139,8 @@ class KeyhandlerDBUSService(dbus.service.Object): @dbus.service.method('org.elektranox.keyhandler') def backlightInc(self): brightness = self._getBacklight() + 5 - if brightness > 255: - brightness = 255 + if brightness > self._getMaxBacklight(): + brightness = self._getMaxBacklight() self._setBacklight(brightness) self._showBacklightState() -- cgit v1.2.3