"hwo to make a script to give track battery and give notification" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "hwo to make a script to give track battery and give notification" answered properly. Developers are finding an appropriate answer about hwo to make a script to give track battery and give notification related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like hwo to make a script to give track battery and give notification. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on hwo to make a script to give track battery and give notification.
hwo to make a script to give track battery and give notification
import psutil
import time
import pyttsx3
from win10toast import ToastNotifier # also need to install win32api
import threading
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_indicator.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 < 40:
if plugged == False:
processThread = threading.Thread(target=show_notification, args=("Your Battery at "+str(percent)+"% Please plug the cable",)) # <- note extra ','
processThread.start()
x.say("Your battery is getting low so charge it right now")
x.runAndWait()
count = 0
elif percent == 100:
if plugged == True:
processThread = threading.Thread(target=show_notification, args=("Charging is getting complete",)) # <- note extra ','
processThread.start()
x.say("Charging is getting complete")
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()
Source: dev.to
All those coders who are working on the C++ based application and are stuck on hwo to make a script to give track battery and give notification can get a collection of related answers to their query. Programmers need to enter their query on hwo to make a script to give track battery and give notification related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about hwo to make a script to give track battery and give notification for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of hwo to make a script to give track battery and give notification while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "hwo to make a script to give track battery and give notification". Visit this developer's friendly online web community, CodeProZone, and get your queries like hwo to make a script to give track battery and give notification resolved professionally and stay updated to the latest C++ updates.