-
Notifications
You must be signed in to change notification settings - Fork 6
/
battery.py
33 lines (30 loc) · 1.46 KB
/
battery.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
import os
import time
from gi.repository import Notify
import commands
def battery():
try:
state=commands.getoutput('upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state"')
print state
# Run till battery is fully charged
full=0
while(full==0):
state=commands.getoutput('upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state"')
print commands.getoutput('clear')
print state
if(state==' state: fully-charged'):
full=1
print "FULLY CHARGED"
# Reminding every minute when battery is fully charged
while state==' state: fully-charged':
Notify.init("BAT FULL")
st=Notify.Notification.new("Battery","fully-charged","dialog-information")
st.show()
state=commands.getoutput('upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state"')
if(state!=' state: fully-charged'):
battery()
time.sleep(60)
# battery() # call itself when the charge is disconnected
except:
print "interrupted..Exiting"
battery()