From 25eefe46230a5285c53a4bf5c63022b2458706dc Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Fri, 30 Apr 2021 16:32:46 -0400 Subject: added openweather API based weather script --- weather.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 weather.sh 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" -- cgit v1.2.3