fix output
This commit is contained in:
parent
8b696b03e4
commit
72093c16b6
|
@ -7,12 +7,25 @@ module_config
|
|||
[ "$ENABLE_ITEM5" = "true" ] || exit
|
||||
command -v curl > /dev/null || exit
|
||||
|
||||
WEATHER_FULL="$(echo "$(curl -s wttr.in/?format="%C" || exit), $(curl -s wttr.in/?format=3 | sed 's/.* //; s/.*\(.....\)/\1/')")"
|
||||
echo "$WEATHER_FULL" | grep -qE "Unknown location|<html>| ," && exit
|
||||
# weather data
|
||||
DATA1="$(curl -s wttr.in/?format="%C")"
|
||||
DATA2="$(curl -s wttr.in/?format=3 | sed 's/.* //; s/.*\(.....\)/\1/')"
|
||||
|
||||
# if no internet connection/it failed to download
|
||||
[ -z "$DATA1" ] && printf "No internet connection.\n" > /tmp/module_weather_log && exit 1
|
||||
|
||||
# full data
|
||||
# TODO: formatting support
|
||||
WEATHER_FULL="$(echo "$DATA1, $DATA2")"
|
||||
|
||||
# if unknown location or <html> tag, exit
|
||||
echo "$WEATHER_FULL" | grep -qE "Unknown location|<html>" && printf "Invalid data.\n" > /tmp/module_weather_log && exit 1
|
||||
|
||||
GETICON() {
|
||||
# default to no icon, we'll override this with $ITEM5_ICON if -z
|
||||
ICON=""
|
||||
|
||||
# check icon
|
||||
echo "$WEATHER_FULL" | grep -qE "Cloudy|cloudy" && ICON=CLOUDY
|
||||
echo "$WEATHER_FULL" | grep -qE "Windy|windy|wind" && ICON=WINDY
|
||||
echo "$WEATHER_FULL" | grep -qE "Fog|fog|Foggy|foggy" && ICON=FOGGY
|
||||
|
|
Loading…
Reference in a new issue