summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2021-04-30 16:32:46 -0400
committerAdam T. Carpenter <atc@53hor.net>2021-04-30 16:32:46 -0400
commit25eefe46230a5285c53a4bf5c63022b2458706dc (patch)
tree11a45cbcc50dbf86e4f7ab91f9a0c2e8de93ebb6
parent186125d7512bd4dd095cd7b60bc648eb603c2290 (diff)
downloadscripts-25eefe46230a5285c53a4bf5c63022b2458706dc.tar.xz
scripts-25eefe46230a5285c53a4bf5c63022b2458706dc.zip
added openweather API based weather script
-rwxr-xr-xweather.sh56
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"