-
Notifications
You must be signed in to change notification settings - Fork 0
/
Batter Percentage Reminder App.py
69 lines (58 loc) · 1.93 KB
/
Batter Percentage Reminder App.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#imports
from email import message
from socket import timeout
from turtle import title
import psutil
from plyer import notification
battery = psutil.sensors_battery()
plugged = battery.power_plugged
if __name__=="__main__":
if plugged:
percent = battery.percent
if percent <= 80:
notification.notify(
#give notif a title
title = "Charging",
#message content for notif
message = "To preserve battery life, charge up to 80%",
#display time
timeout = 2
)
elif percent == 100:
notification.notify(
title = "Charging",
message = "Battery is fully charged, please unplug charger.",
timeout = 2
)
else:
notification.notify(
title = "Charging",
message = "To preserve battery life, charge up to 80%",
timeout = 2
)
else:
percent = battery.percent
if percent <= 20:
notification.notify(
title = "Low Battery!",
message = "Your battery is running low. Please plug in your PC.",
timeout = 2
)
elif percent <= 50:
notification.notify(
title = "Battery Percentage",
message = f'Battery is at {percent}',
timeout = 2
)
elif percent == 100:
notification.notify(
title = "Fully Charged!",
message = "Your battery is fully charged.",
timeout = 2
)
else:
notification.notify(
title = "Battery Percentage",
message = f'Battery is at {percent}',
timeout = 2
)