diff options
Diffstat (limited to 'weather.sh')
-rwxr-xr-x | weather.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/weather.sh b/weather.sh new file mode 100755 index 0000000..f87f7b5 --- /dev/null +++ b/weather.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +API_KEY="$(cat ~/.config/openweathermap)" +ZIP_CODE=23435 + +while read line +do + case $line in + icon*) + case "${line#icon }" in + 01d) + ICON= + ;; + 02d) + ICON= + ;; + 03d|04d) + ICON= + ;; + 09d|10d) + ICON= + ;; + 11d) + ICON= + ;; + 13d) + ICON= + ;; + 50d) + ICON= + ;; + esac + + #printf "$ICON" + ;; + description*) + #printf "${line#description }" + DESCRIPTION="${line#description }" + ;; + humidity*) + #printf "%.2d%% " "${line#humidity }" + HUMIDITY="${line#humidity }" + ;; + feels_like*) + #printf "%2.1f℉ " "${line#feels_like }" + FEELS_LIKE="${line#feels_like }" + ;; + esac +done << EOF +$(fetch -qo - "https://api.openweathermap.org/data/2.5/weather?zip=$ZIP_CODE&units=imperial&appid=$API_KEY" \ + | tr -d '"{}[]' \ + | tr ',' '\n' \ + | tr ':' ' ') +EOF + +printf "%s%s %2.1f℉ %.2d%%\n" "$ICON" "$DESCRIPTION" "$FEELS_LIKE" "$HUMIDITY" |