-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_weather
executable file
·35 lines (29 loc) · 934 Bytes
/
mod_weather
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
#!/usr/bin/env bash
. .dzenbarrc
MONITOR=${1}
PIPE_LINE=${2}
while true; do
cache='/tmp/weather.cache'
weather ${WEATHER_SEARCH} -q -m --no-cache-data > ${cache} 2> /dev/null
if [[ $? == 0 ]]; then
w_temp=$(cat ${cache} | awk '/Temperature/ {print $2}')
w_humidity=$(cat ${cache} | awk '/Humidity/ {print $3}')
w_sky=""
#w_sky=$(cat ${cache} | awk '/Sky conditions/ {for(i=3;i<=NF;i++) print $i}' | sed ':a;N;$!ba;s/\n/ /g')
#
#if [[ -n ${w_sky} ]]; then
# w_sky="${w_sky}, "
#fi
w_wind=$(cat ${cache} | awk -F KPH '/Wind/ {print $1}' | awk '{print $NF}')
if [[ "${w_wind}" =~ ^[0-9]+$ ]]; then
w_wind="${w_wind} kph, "
elif [[ -n ${w_wind} ]]; then
w_wind="${w_wind,,}, "
fi
output=" $(iconColor 'weather') ${w_wind}$(textColor 't:') ${w_temp}°C$(textColor ', h:') ${w_humidity}"
putLineToPipeFile ${MONITOR} ${PIPE_LINE} "${output}"
sleep ${WEATHER_UPDATE}
else
sleep 1m
fi
done