forked from HarshCasper/Rotten-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbattery_full_charged_notifier.pyw
More file actions
44 lines (39 loc) · 1.51 KB
/
battery_full_charged_notifier.pyw
File metadata and controls
44 lines (39 loc) · 1.51 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
34
35
36
37
38
39
40
41
42
43
44
import psutil #Library to get System details
import time
import pyttsx3 # Library for text to speech Offline
from win10toast import ToastNotifier # also need to install win32api (This is for Notifications)
import threading # To make notification and speech work at same time
toaster = ToastNotifier()
x=pyttsx3.init()
x.setProperty('rate',130)
x.setProperty('volume',8)
count = 0
def show_notification(show_text):
toaster.show_toast(show_text,
icon_path='battery.ico',
duration=10)
# loop the toaster over some period of time
while toaster.notification_active():
time.sleep(0.1)
def monitor():
while (True):
time.sleep(10)
battery = psutil.sensors_battery()
plugged = battery.power_plugged
percent = int(battery.percent)
if percent == 100:
if plugged == True:
processThread = threading.Thread(target=show_notification, args=("Laptop Fully Charged",)) # <- note extra ','
processThread.start()
x.say("Laptop is Fully Charged Please plug out the cable")
x.runAndWait()
elif percent == 90:
if plugged == True:
if count == 0:
processThread = threading.Thread(target=show_notification, args=("Your Battery at 90% Please plug out the cable",)) # <- note extra ','
processThread.start()
x.say("Your battery at 90% ")
x.runAndWait()
count = count + 1
if __name__ == "__main__":
monitor()