forked from geekcomputers/Python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattery_notifier.py
More file actions
Latest commit
25 lines (21 loc) · 728 Bytes
/
Copy pathBattery_notifier.py
File metadata and controls
25 lines (21 loc) · 728 Bytes
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
fromplyerimportnotification# pip install plyer
importpsutil# pip install psutil
# psutil.sensors_battery() will return the information related to battery
battery=psutil.sensors_battery()
# battery percent will return the current battery prcentage
percent=battery.percent
charging= (
battery.power_plugged
)
# Notification(title, description, duration)--to send
# notification to desktop
# help(Notification)
ifcharging:
ifpercent==100:
charging_message="Unplug your Charger"
else:
charging_message="Charging"
else:
charging_message="Not Charging"
message=str(percent) +"% Charged\n"+charging_message
notification.notify("Battery Information", message, timeout=10)