screen/weather: Show snow status as bg color
parent
e07c4e591f
commit
0c6fc94a54
|
@ -29,11 +29,7 @@ export -n HTTP_PROXY http_proxy
|
||||||
# fall back to realtime weather data if no cache is available
|
# fall back to realtime weather data if no cache is available
|
||||||
wdata=/tmp/.weather
|
wdata=/tmp/.weather
|
||||||
data="$(
|
data="$(
|
||||||
if [ -s "$wdata" ]; then
|
cat /tmp/.weather 2>/dev/null \
|
||||||
cat /tmp/.weather
|
|
||||||
else
|
|
||||||
weather -i "${WEATHER_METAR:-kbuf}"
|
|
||||||
fi \
|
|
||||||
| sed 's/^ \+//g'
|
| sed 's/^ \+//g'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
@ -48,6 +44,12 @@ weather_c="$( echo "$weather_temp" \
|
||||||
| grep -oP '[0-9\.-]+ C' \
|
| grep -oP '[0-9\.-]+ C' \
|
||||||
| cut -d' ' -f1 \
|
| 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" \
|
wind="$( grep -o '[0-9]\+ MPH' <<< "$data" \
|
||||||
| tr '\n' '-' \
|
| tr '\n' '-' \
|
||||||
| sed 's/-$//;s/ \?MPH-/-/' \
|
| sed 's/-$//;s/ \?MPH-/-/' \
|
||||||
|
@ -70,10 +72,15 @@ else
|
||||||
color=m # purple with my color scheme
|
color=m # purple with my color scheme
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
bgcolor='.'
|
||||||
|
if [[ "$weather_type" =~ snow ]]; then
|
||||||
|
bgcolor=w
|
||||||
|
fi
|
||||||
|
|
||||||
# if it's sunny, make the status brighter
|
# if it's sunny, make the status brighter
|
||||||
echo "$data" | grep -qP 'sunny|(mostly )?clear|partly cloudy' && {
|
echo "$data" | grep -qP 'sunny|(mostly )?clear|partly cloudy' && {
|
||||||
color=$( echo $color | tr '[:lower:]' '[:upper:]' )
|
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{-}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue