blob: f87f7b56b92e5bb8e40682c1d9d20f291e0fcb35 (
plain) (
tree)
|
|
#!/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"
|