Last active
August 31, 2016 13:21
-
-
Save mmueller/5553027 to your computer and use it in GitHub Desktop.
This is an ugly-ass hack to temporarily fix a brightness jumping problem with some nvidia-based laptops on Linux, until nvidiabl/nvidia drivers fix the issue. Watches the actual brightness of the display, and when it jumps up past the maximum, resets it to the original desired value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import time | |
BACKLIGHT = 'nvidia_backlight' | |
DELAY = 0.2 | |
def get_value(name): | |
path = os.path.join('/sys/class/backlight', BACKLIGHT, name) | |
return int(open(path, 'r').read()) | |
def set_value(name, value): | |
path = os.path.join('/sys/class/backlight', BACKLIGHT, name) | |
open(path, 'w').write(str(value)) | |
def watch_brightness(): | |
maximum = get_value('max_brightness') | |
while True: | |
actual = get_value('actual_brightness') | |
if actual > maximum: | |
desired = get_value('brightness') | |
set_value('brightness', desired) | |
time.sleep(DELAY) | |
if __name__ == '__main__': | |
watch_brightness() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See discussion here: guillaumezin/nvidiabl#56