From d4ea79d054b03da437905b912ae92238685c8c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Fri, 29 Dec 2023 10:23:21 +0300 Subject: [PATCH] Make dim-screen smarter --- scripts/dim-screen | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/dim-screen b/scripts/dim-screen index d58b3f8..e85669c 100755 --- a/scripts/dim-screen +++ b/scripts/dim-screen @@ -23,7 +23,18 @@ def smooth_dimming(initial_brightness, final_brightness, duration, steps): subprocess.call(['light', '-O']) initial_brightness = float(subprocess.getoutput('light')) -final_brightness = 0 if initial_brightness < 20 else 5 +if initial_brightness < 20: + final_brightness = max(0, initial_brightness - 10) +elif initial_brightness < 40: + final_brightness = max(10, initial_brightness - 20) +elif initial_brightness < 60: + final_brightness = max(30, initial_brightness - 30) +elif initial_brightness < 80: + final_brightness = max(40, initial_brightness - 40) +elif initial_brightness < 100: + final_brightness = max(50, initial_brightness - 50) + + dimming_duration = 0.3 if initial_brightness < 20 else .5 num_steps = 20 if initial_brightness < 20 else 50