-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstatck
executable file
·97 lines (88 loc) · 2.12 KB
/
statck
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
#!/bin/sh
# Fernando Carmona Varo <[email protected]>
# Time-stamp: <2011-04-15 13:19:13 ferk>
#----
# This script checks for temperature and battery and displays a notification
# (using notify-send) if the limits are too high.
#
# It can either execute a single time, or be run as a daemon (statck -d) that
# will re-run the check each minute.
#
# It has also an option to show the status as a single line (statck -1) which
# can be used for displaying it at applications status line.
#----
hash notify-send 2>&- && {
NOTIFY='notify-send -u critical -i "dialog-warning.png" '
} || {
osd() {
echo $@ | osd_cat -O 3 -o 12 -c white -A center -d 10 -f "-*-droid sans-*-*-*-*-*-*-*-*-*-*-*"
}
NOTIFY='osd'
}
####
# tempck: Temperature Checking
####
tempck () {
TEMP=$(sensors | grep -o -e "+.....C[ \n]")
NTEMP=$(echo "$TEMP" | cut -c "2-3")
AVGTEMP=0
for i in $NTEMP
do
if [ $i -gt 80 ]
then
#notify-send "DANGER!! High temp ($TEMP)" -u critical -i dialog-warning -h string:synchronouns:"tempsensor"
$NOTIFY "DANGER!! High temp ($TEMP)"
fi
AVGTEMP=$(($AVGTEMP + $i))
N=$(($N+1))
done
AVGTEMP=$((${AVGTEMP}/${N}))
}
####
# battck: Battery Checking
####
battck () {
BATT=$(acpi -b | cut -d, -f 2 | cut -c 2-)
NBATT="$(echo "$BATT" | cut -f 1 -d "%")"
for i in $NBATT
do
# if [ "$i" -gt "98" -o "$i" -lt "15" ]
if [ "$i" -lt "15" ]
then
#notify-send "Battery $BATT!!" -u critical -i "dialog-warning.png" -h string:synchronouns:"battsensor"
$NOTIFY "Battery $BATT!!"
fi
done
}
####
####
if [ "$#" -eq "0" ]
then
tempck
printf "- Temp:\n$TEMP"
battck
[ -n "$BATT" ] && printf "- Batt:\n$BATT"
else
if [ "$1" = "-d" ]
then
while true
do
tempck
battck
sleep 60
done &
echo "Daemon started"
else
if [ "$1" = "-1" ]
then
tempck
battck
#echo "♨${AVGTEMP}ºC♨ ⚡${BATT}⚡"
printf "${AVGTEMP}ºC"
test -n "$BATT" && printf "|${BATT}"
echo
else
echo "usage: checktemp [-d] [-1]"
fi
fi
fi