-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus
executable file
·86 lines (68 loc) · 1.46 KB
/
status
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
#!/bin/sh
audio() {
pulsemixer --get-mute | sed -e 's/0/ /' -e 's/1/ /' | tr -d '\n'
pulsemixer --get-volume | awk '{print $1}'
}
datetime() {
echo " " | tr -d '\n'
date '+%b %d %I:%M%p'
}
link() {
ping -q -c 1 1.1.1.1 > /dev/null 2>&1 && echo " " || echo " "
}
memory() {
echo " " | tr -d '\n'
free -m | awk 'NR==2{print $3}' | tr -d '\n'
echo "mb"
}
temperature() {
echo " " | tr -d '\n'
sensors coretemp-isa-0000 | awk 'NR==3{gsub("+","");print $4}'
}
weather() {
curl -s wttr.in/3189?format=1 | sed 's/ //'
}
genstatus() {
printf -v status "| %s | %s | %s | %s | %s | %s |" \
"$audio_stdo" "$link_stdo" "$memory_stdo" "$temperature_stdo" "$weather_stdo" "$datetime_stdo"
}
drawstatus() {
xsetroot -name "$(echo $status | tr -d '\n')"
}
test() {
filename="$1"
current="$($1)"
eval previous='$'${filename}_stdo
if [ "$current" != "$previous" ]; then
refr="yes"
fi
eval "${filename}_stdo='$current'"
}
i=0
while :; do
# update every 1 second
if (( $i%1 == 0 )); then
test audio
fi
# update every 5 seconds
if (( $i%5 == 0 )); then
test temperature
test memory
fi
#update every 10 seconds
if (( $i%10 == 0 )); then
test datetime
test link
fi
#update every 10 minutes
if (( $i%600 == 0 )); then
test weather
fi
if [ "$refr" = "yes" ]; then
genstatus
drawstatus
refr="no"
fi
(( i++ ))
sleep 1
done