summaryrefslogtreecommitdiffstats
path: root/tp-key-handler
diff options
context:
space:
mode:
Diffstat (limited to 'tp-key-handler')
-rwxr-xr-xtp-key-handler10
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()