2022-07-04 21:36:33 +02:00
|
|
|
#!/bin/sh
|
2022-08-22 20:33:37 +02:00
|
|
|
|
|
|
|
# Options can be found at https://wttr.in/:help
|
2023-02-09 15:29:14 +01:00
|
|
|
|
|
|
|
weatherfile="$XDG_CACHE_HOME/weatherreport"
|
|
|
|
emojifile="$XDG_CACHE_HOME/weatheremoji"
|
|
|
|
url="wttr.in/?FA"
|
|
|
|
|
|
|
|
getforecast() {
|
|
|
|
curl -sf4 "$url" >$weatherfile || exit 1
|
|
|
|
curl -sf4 "$url&format=%c" | sed 's/☀️//;s/☁️//;s/⛅️//;s/⛈//;s/✨//;s/❄️//;s/🌦//;s/🌧//;s/🌨//;s/🌩//;s/🌫//;' >$emojifile || exit 1
|
2022-07-04 21:36:33 +02:00
|
|
|
}
|
2023-02-07 17:19:53 +01:00
|
|
|
showweather() {
|
2023-02-09 15:29:14 +01:00
|
|
|
emoji="$(printf "\033[12m%s\033[10m" $(cut -d ' ' -f 1 $emojifile))"
|
|
|
|
sed '16q;d' $weatherfile | grep -wo "[0-9]*%" | sort -rn | sed "s/^/$emoji /g;1q" | tr -d '\n'
|
2023-02-21 17:49:55 +01:00
|
|
|
sed '13q;d' $weatherfile | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " \033[34;11m\033[0m " $1 "°","\033[31;11m\033[0m " $2 "°"}'
|
2022-08-22 20:33:37 +02:00
|
|
|
}
|
2023-02-09 15:29:14 +01:00
|
|
|
getforecast
|
2022-07-04 21:36:33 +02:00
|
|
|
showweather
|