1
0
Fork 0

screen/weather: Show snow status as bg color

master
Mike Gerwitz 2018-04-06 09:46:50 -04:00
parent e07c4e591f
commit 0c6fc94a54
1 changed files with 13 additions and 6 deletions

View File

@ -29,11 +29,7 @@ export -n HTTP_PROXY http_proxy
# fall back to realtime weather data if no cache is available
wdata=/tmp/.weather
data="$(
if [ -s "$wdata" ]; then
cat /tmp/.weather
else
weather -i "${WEATHER_METAR:-kbuf}"
fi \
cat /tmp/.weather 2>/dev/null \
| sed 's/^ \+//g'
)"
@ -48,6 +44,12 @@ weather_c="$( echo "$weather_temp" \
| grep -oP '[0-9\.-]+ C' \
| cut -d' ' -f1 \
)"
# filters out e.g. "N inches of snow on ground"
weather_type="$( echo "$data" \
| grep '^Weather: ' \
| grep -v ' on ground' \
| cut -d' ' -f2- \
)"
wind="$( grep -o '[0-9]\+ MPH' <<< "$data" \
| tr '\n' '-' \
| sed 's/-$//;s/ \?MPH-/-/' \
@ -70,10 +72,15 @@ else
color=m # purple with my color scheme
fi
bgcolor='.'
if [[ "$weather_type" =~ snow ]]; then
bgcolor=w
fi
# if it's sunny, make the status brighter
echo "$data" | grep -qP 'sunny|(mostly )?clear|partly cloudy' && {
color=$( echo $color | tr '[:lower:]' '[:upper:]' )
}
echo -e "\005{+ .$color}${weather_f}F/${weather_c}C $wind\005{-}"
echo -e "\005{+ $bgcolor$color}${weather_f}F/${weather_c}C $wind\005{-}"