Make dim-screen smarter

This commit is contained in:
Şahin Akkaya 2023-12-29 10:23:21 +03:00
parent 17cfe1ba66
commit d4ea79d054

View File

@ -23,7 +23,18 @@ def smooth_dimming(initial_brightness, final_brightness, duration, steps):
subprocess.call(['light', '-O']) subprocess.call(['light', '-O'])
initial_brightness = float(subprocess.getoutput('light')) 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 dimming_duration = 0.3 if initial_brightness < 20 else .5
num_steps = 20 if initial_brightness < 20 else 50 num_steps = 20 if initial_brightness < 20 else 50