summary refs log tree commit diff
path: root/.config/waybar/modules/weather.sh
blob: 9f7780d2f08bc7c92e804bb49a6a0fd7649e084a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
set -e
[ -n "$DEBUG" ] && set -x

loc=$1

if [ -n "$REPORT" ]; then
	curl -s v2.wttr.in/"${loc}"?F | less
	exit 0
fi

curl -s wttr.in/"${loc}"?format=j1 \
	| jq \
	--raw-output \
	--unbuffered \
	--compact-output \
	--arg tooltip "$(curl -s v2.wttr.in/"${loc}"?ATFQ | tail -n5)" \
	'.current_condition[] | { text: .weatherDesc[0].value, percentage: (.temp_C | tonumber), class: .weatherCode, alt: .weatherCode, tooltip: ($tooltip) }'