-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifier.py
executable file
·53 lines (45 loc) · 1.78 KB
/
notifier.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
import psutil
import os
from playsound import playsound
import time
def percent_check():
# returns a tuple
battery = psutil.sensors_battery()
percent = battery.percent
charging= battery.power_plugged
# Checking percent
if percent <= 20:
percent = str(percent)
percent= percent[:2]
if charging:
os.system("notify-send '" +' ' + '\U0001F979' + 'percent%' + "' '" + percent + "'")
playsound('Music/BatteryNotifySound/mixkit-melodical-flute-music-notification-2310.wav')
time.sleep(120)
else:
percent = str(percent)
percent= percent[:2]
os.system("notify-send '" +' ' + '\U0001F97A' + 'percent%' + "' '" + percent + "'")
playsound('Music/BatteryNotifySound/mixkit-wrong-answer-fail-notification-946.wav')
time.sleep(180)
elif percent >= 30 and percent <= 33 and not charging:
percent = str(percent)
percent= percent[:2]
os.system("notify-send '" + ' '+ '\U0001F645' + 'percent%' + "' '" + percent + "'")
playsound('Music/BatteryNotifySound/mixkit-bell-notification-933.wav')
time.sleep(300)
# I think reminding when its around 30% once is enough.
elif percent >=93 and charging:
percent = str(percent)
percent= percent[:2]
os.system("notify-send '"+ ' '+ '\U0001F525' + 'percent%' + "' '" + percent + "'")
playsound('Music/BatteryNotifySound/mixkit-bell-notification-933.wav')
playsound('Music/BatteryNotifySound/mixkit-happy-bells-notification-937.wav')
time.sleep(75)
else: # To check every 2 minutes
time.sleep(120)
while True:
percent_check()
'''
To Add notifier to startup apps.
See the README.md file
'''