diff options
author | Sebastian Reichel <sre@ring0.de> | 2017-10-29 14:04:13 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2017-10-29 14:04:13 +0100 |
commit | e33ea82dc52ad66d6e191e75a07fcb03375682a9 (patch) | |
tree | 333ee003da2f315452c7cf69666374e46930a802 | |
parent | 1c47c30c3ff646b446c0632974c3397836196f2c (diff) | |
download | tp-key-handler-e33ea82dc52ad66d6e191e75a07fcb03375682a9.tar.bz2 |
max brightness is > 255 on X250
-rwxr-xr-x | tp-key-handler | 10 |
1 files 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() |