summary refs log tree commit diff
path: root/.config/waybar/modules/weather.sh
diff options
context:
space:
mode:
Diffstat (limited to '.config/waybar/modules/weather.sh')
-rwxr-xr-x.config/waybar/modules/weather.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/.config/waybar/modules/weather.sh b/.config/waybar/modules/weather.sh
new file mode 100755
index 0000000..9f7780d
--- /dev/null
+++ b/.config/waybar/modules/weather.sh
@@ -0,0 +1,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) }'
+