-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpower_check.sh
executable file
·98 lines (90 loc) · 4.17 KB
/
power_check.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#-------------------------------------------------------------------------------------------------------------------------
# Power system checking function
#-------------------------------------------------------------------------------------------------------------------------
sp=$(upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | grep "state")
st=$(upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | grep "time to full")
sd=$(upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | grep "time to empty")
ss=$(cat /sys/class/power_supply/BAT0/capacity)
#--------------------------------------------------------------------------#--------------------------------------------------------------------------
echo " "
echo " ---------------------------------------------------------------------"
echo " Checking power level"
echo " ---------------------------------------------------------------------"
espeak -g5 -s180 "Checking power level " -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " "
#--------------------------------------------------------------------------#--------------------------------------------------------------------------
espeak -g5 -s180 " Power level $ss percentage" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Power level $ss percentage"
echo " "
#-----------------------------------state checking ----------------------------------------------------------------------
espeak -g5 -s180 " Checking power state " -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Checking power state "
echo " "
upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | grep "state"
if [ -z "$sd" ]
then
#--------------------------------------------------------------------------#--------------------------------------------------------------------------
espeak -g5 -s180 "$sp" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
espeak -g5 -s180 "$st" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " "
upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | grep "time to full"
echo " "
else
#--------------------------------------------------------------------------#--------------------------------------------------------------------------
espeak -g5 -s180 "$sp" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
espeak -g5 -s180 "$sd" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " "
upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | grep "time to empty"
echo " "
fi
i=1
#------------------------------------checking if need backup --------------------------------------------------------------
while [ $i -lt 3 ]
do
pp=$(upower -i $(upower -e | grep BAT) | grep --color=never -E state)
op="state:"
rv=$(./string_split.sh "$pp" "$op")
#--------------------------------------------------------------------------
if [ $ss -lt 10 ] && [ $rv == 'discharging' ]
then
sleep 0.5
espeak -a400 -s150 " Warning" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
espeak -a400 " Power system critical please charge your system " -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Warning: Power System Critical !!!!!!! Please Charge Your System !!!!!!!!!!!! "
#--------------------------------------------------------------------------
if [ $i == 1 ]
then
./brightness_update.sh "$ss"
i=2
fi
#--------------------------------------------------------------------------
else
sleep 0.3
espeak " Power system looking good" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
./brightness_update.sh "$ss"
echo " Power System Looking Good"
break
fi
done
echo " ----------------------------------------------------------------------"
#----------------------------------------------------------------------------------------------------------------------------