This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/scripts/.local/bin/forecast

40 lines
882 B
Plaintext
Raw Normal View History

2019-10-16 02:28:41 +02:00
#!/bin/sh
2019-12-01 17:36:00 +01:00
set -e
2019-10-16 02:28:41 +02:00
CITY=$(curl -s ipinfo.io/city)
APPID="fd68c0fe7951f5ab7e24a240eb0942b8"
2019-12-02 19:57:45 +01:00
FORECAST=$(http get http://api.openweathermap.org/data/2.5/forecast\?APPID\=${APPID}\&q\="${CITY}"\&units\=metric)
2019-10-16 02:28:41 +02:00
2019-12-02 19:57:45 +01:00
TEMP=$(echo $FORECAST | jq -r ".list[0].main.temp")
WEATHER=$(echo $FORECAST | jq -r ".list[0].weather[0].main")
MIN=$(echo $FORECAST | jq -r ".list[2].main.temp_min" |
perl -pe 's/(\d*)\.\d*/\1/')
MAX=$(echo $FORECAST | jq -r ".list[2].main.temp_max" |
perl -pe 's/(\d*)\.\d*/\1/')
2019-10-16 02:28:41 +02:00
case $WEATHER in
2019-12-01 17:36:00 +01:00
"Clear")
2019-12-02 19:57:45 +01:00
WEATHER=" "
2019-10-16 02:28:41 +02:00
;;
2019-12-01 17:36:00 +01:00
"Clouds")
2019-12-02 19:57:45 +01:00
WEATHER=" "
2019-10-16 02:28:41 +02:00
;;
2019-12-01 17:36:00 +01:00
"Rain"|"Drizzle")
2019-12-02 19:57:45 +01:00
WEATHER=" "
2019-10-16 02:28:41 +02:00
;;
2019-12-01 17:36:00 +01:00
"Mist")
2019-11-23 18:35:46 +01:00
WEATHER=" "
;;
2019-12-01 17:36:00 +01:00
"Snow")
2019-12-02 19:57:45 +01:00
WEATHER=" "
2019-10-16 02:28:41 +02:00
;;
2019-12-01 17:36:00 +01:00
"Thunderstorm")
2019-10-16 02:28:41 +02:00
WEATHER=""
;;
esac
2019-12-02 19:57:45 +01:00
text="$MIN $MAX $TEMP°C $WEATHER"
# tooltip="$(curl -s wttr.in | paste -d'\\n' -s )"
tooltip=""
2019-12-05 15:28:02 +01:00
echo "$text"