#!/bin/bash

# I create this scripts to show weather icon with text icon
# and take data from json file, so it can use offline
# the font i use Feather icon font  { https://github.com/AT-UI/feather-font }
# to get weather.json file i use another script
# Closebox73

# icon font based openweathermap.org data
ICON_01D=""
ICON_01N=""
ICON_02D=""
ICON_02N=""
ICON_03D=""
ICON_03N=""
ICON_04D=""
ICON_04N=""
ICON_09D=""
ICON_09N=""
ICON_10D=""
ICON_10N=""
ICON_11D=""
ICON_11N=""
ICON_13D=""
ICON_13N=""
ICON_50D=""
ICON_50N=""

WEATHER_ICON=$(cat ~/.cache/weather.json | jq -r '.weather[0].icon')

if [[ "${WEATHER_ICON}" = *01d* ]]; then
    echo "${ICON_01D}"
elif [[ "${WEATHER_ICON}" = *01n* ]]; then
    echo "${ICON_01N}"
elif [[ "${WEATHER_ICON}" = *02d* ]]; then
    echo "${ICON_02D}"
elif [[ "${WEATHER_ICON}" = *02n* ]]; then
    echo "${ICON_02N}"
elif [[ "${WEATHER_ICON}" = *03d* ]]; then
    echo "${ICON_03D}"
elif [[ "${WEATHER_ICON}" = *03n* ]]; then
    echo "${ICON_03N}"
elif [[ "${WEATHER_ICON}" = *04d* ]]; then
    echo "${ICON_04D}"
elif [[ "${WEATHER_ICON}" = *04n* ]]; then
    echo "${ICON_04N}"
elif [[ "${WEATHER_ICON}" = *09d* ]]; then
    echo "${ICON_09D}"
elif [[ "${WEATHER_ICON}" = *09n* ]]; then
    echo "${ICON_09N}"
elif [[ "${WEATHER_ICON}" = *10d* ]]; then
    echo "${ICON_10D}"
elif [[ "${WEATHER_ICON}" = *10n* ]]; then
    echo "${ICON_10N}"
elif [[ "${WEATHER_ICON}" = *11d* ]]; then
    echo "${ICON_11D}"
elif [[ "${WEATHER_ICON}" = *11n* ]]; then
    echo "${ICON_11N}"
elif [[ "${WEATHER_ICON}" = *13d* ]]; then
    echo "${ICON_13D}"
elif [[ "${WEATHER_ICON}" = *13n* ]]; then
    echo "${ICON_13N}"
elif [[ "${WEATHER_ICON}" = *50d* ]]; then
    echo "${ICON_50D}"
elif [[ "${WEATHER_ICON}" = *50n* ]]; then
    echo "${ICON_50N}"
	fi
fi

exit
