2021-03-31 14:43:27 +03:00
|
|
|
#!/bin/sh
|
2022-04-25 04:33:45 +03:00
|
|
|
# Requires jq
|
|
|
|
if ! jq --version &> /dev/null; then
|
|
|
|
echo "Please install jq"
|
|
|
|
exit
|
|
|
|
fi
|
2021-03-31 14:43:27 +03:00
|
|
|
|
2022-04-25 04:33:45 +03:00
|
|
|
URL="https://api.openweathermap.org/data/2.5/onecall"
|
|
|
|
LOCATION="Jyväskylä"
|
|
|
|
LAT_LON="lat=62.23&lon=25.73"
|
|
|
|
EXCLUDE="exclude=minutely,hourly,daily,alerts"
|
|
|
|
UNITS="units=metric"
|
|
|
|
LANG="lang=en"
|
2021-03-31 14:43:27 +03:00
|
|
|
|
2022-04-25 04:33:45 +03:00
|
|
|
# OWM_API_KEY is an environment variable
|
|
|
|
WHOLE="${URL}?${LAT_LON}&${EXCLUDE}&${WEATHER}&${UNITS}&${LANG}&appid=${OWM_API_KEY}"
|
|
|
|
|
|
|
|
DATA=($(curl -s "${WHOLE}" \
|
|
|
|
| jq '.current.temp, .current.feels_like, .current.weather[0].description'))
|
|
|
|
|
|
|
|
DESC="${DATA[@]:2}"
|
|
|
|
|
2022-04-25 04:39:41 +03:00
|
|
|
# If no data, exit
|
|
|
|
if [[ $DATA == *"null"* ]]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-03-03 15:39:19 +02:00
|
|
|
r () {
|
|
|
|
echo $1 | sed 's/\./\,/'
|
|
|
|
}
|
|
|
|
|
|
|
|
w="$(r ${DATA[0]})"
|
|
|
|
fl="$(r ${DATA[1]})"
|
|
|
|
|
|
|
|
printf "${DESC:1:-1}, $w°C (fl $fl°C)\n"
|