Home

Published

- 1 min read

how to set screen brightness automatically depending on battery percentage using python

img of how to set screen brightness automatically depending on battery percentage using python

The solution for this is noted below

how to set screen brightness automatically depending on battery percentage using python

Solution

   import psutil
import screen_brightness_control as screen
while True:
    battery =  psutil.sensors_battery()
    if battery.power_plugged == True:
        screen.set_brightness(50)
    elif battery.percent >= 30 and battery.power_plugged == False:
        screen.set_brightness(0)

Try other methods by searching on the site. That is if this doesn’t work