1import psutil
2import time
3import pyttsx3
4import os
5while True:
6 time.sleep(5)
7 battery = psutil.sensors_battery()
8 print("Battery percentage : ", battery.percent)
9 print("Power plugged in : ", battery.power_plugged)
10 print()
11 if battery.percent < 25 and battery.power_plugged == False:
12 print("Your battey is low on power")
13 pyttsx3.speak("Your battery is low on power")
14 if battery.percent <= 20 and battery.power_plugged == False:
15 pyttsx3.speak("power in fast")
16 time.sleep(5)
17 pyttsx3.speak("Turning my prosegers on")
18 time.sleep(10)
19 if battery.power_plugged == False: os.system("shutdown /s /t 1")
20 elif battery.percent > 95 and battery.power_plugged == True:
21 pyttsx3.speak("Your laptop has charged enough")
22 print("Your laptop has charged enough")