aboutsummaryrefslogtreecommitdiff
path: root/scripts/weather
blob: 7d7d6a36c54513837f09f1ea458aa72b337d3747 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/zsh

get_current_temp() {
	if [ $stat = "Smoke" ]; then
		temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $4 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g")
	elif [ $stat = "Haze" ] || [ $stat = "Fog" ] || [ $stat = "Shallow" ]; then
		temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $9 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g")
	fi

	echo $temp
}

get_current_weather() {
 	stat=$(curl wttr.in | awk 'NR==3 {print $1}')
	echo $(get_current_temp) "("$stat")"
}

while :; do
	echo $(get_current_weather) > /tmp/weather_stat
	sleep 3600
done