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)