summaryrefslogtreecommitdiffstats
path: root/.local/bin/status/sb-forecast
blob: 0f7aa5205befbfe370704881e74d69e501c19c1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

weatherreport="/tmp/weatherreport"

getweather() {
	curl -sf "wttr.in/lyon" >$weatherreport || exit 1
}

[ -f $weatherreport ] && [ "$(gnustat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || getweather

printf "%s" "$(sed '16q;d' "$weatherreport" |
grep -wo "[0-9]*%" | sort -rn | sed "s/^/  /g;1q" | tr -d '\n')"

sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' |
	sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' |
	awk '{print " ﰕ " $1 "°C","  " $2 "°C"}'

# weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"