-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
33 lines (26 loc) · 1.15 KB
/
script.py
File metadata and controls
33 lines (26 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# win10toast library for Toast notifications
from win10toast import ToastNotifier
# psutil library for monitoring battery and charge status
from psutil import sensors_battery
import time
toaster = ToastNotifier()
isNotifiedLow = False
isNotifiedHigh = False
battery = sensors_battery()
isPlugged = battery.power_plugged
batteryPercent = battery.percent
while(True):
if batteryPercent <= 35 and isPlugged == False and isNotifiedLow == False:
toaster.show_toast("Plug the charger", "Your battery percentage is getting low. \nPlease plug the charger!")
isNotifiedLow = True
elif batteryPercent <= 35 and isPlugged == True and isNotifiedLow == True:
isNotifiedLow = False
elif batteryPercent >= 85 and isPlugged == True and isNotifiedHigh == False:
toaster.show_toast("Unplug the charger", "Battery is now sufficiently charged. \nYou may unplug the charger!")
isNotifiedHigh = True
elif batteryPercent >= 85 and isPlugged == False and isNotifiedHigh == True:
isNotifiedHigh = False
battery = sensors_battery()
isPlugged = battery.power_plugged
batteryPercent = battery.percent
time.sleep(30)