diff --git a/userspace/files/brightnessd.service b/userspace/files/brightnessd.service index a749c26..1dc9636 100644 --- a/userspace/files/brightnessd.service +++ b/userspace/files/brightnessd.service @@ -2,7 +2,7 @@ Description=Limit display brightness with uptime [Service] -Restart=always +Restart=on-failure ExecStart=/usr/local/pyenv/shims/python -u /usr/comma/brightnessd.py [Install] diff --git a/userspace/usr/comma/brightnessd.py b/userspace/usr/comma/brightnessd.py index fee3197..3ce51e0 100755 --- a/userspace/usr/comma/brightnessd.py +++ b/userspace/usr/comma/brightnessd.py @@ -12,6 +12,10 @@ MAX_PERCENT = 90 MIN_PERCENT = 30 HOURLY_PERC_DECREASE = 5 +IGNORED_PANELS = [ + "dsi_mate10_lite_video_display", +] + def read(path: str) -> int: try: with open(path) as f: @@ -22,9 +26,19 @@ def read(path: str) -> int: if __name__ == "__main__": + # detect panel type + with open("/sys/module/msm_drm/parameters/dsi_display0") as f: + d = f.read().strip() + panel = d.split(":")[0] + + print(f"Detected panel '{panel}'") + if panel in IGNORED_PANELS: + print("panel is ignored, exiting") + exit(0) + + # brightness loop last_perc = None last_off_ts = time.monotonic() - while True: try: # sample brightness and backlight power