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

Solutions on MaxInterview for how to set screen brightness automatically depending on battery percentage using python by the best coders in the world

showing results for - "how to set screen brightness automatically depending on battery percentage using python"
Dee
13 Jan 2019
1import psutil
2import screen_brightness_control as screen
3while True:
4    battery =  psutil.sensors_battery()
5    if battery.power_plugged == True:
6        screen.set_brightness(50)
7    elif battery.percent >= 30 and battery.power_plugged == False:
8        screen.set_brightness(0)