Add ens-forecast to xmobar

This commit is contained in:
Daniele Fucini
2026-10-10 09:18:57 +02:00
parent 493d555983
commit a7f19fe2a7
4 changed files with 43 additions and 4 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
# Next day from ens-forecast for xmobar, e.g. "Sat 19/10° 39%" (today before 18:00, then tomorrow)
# With "week": show the next 7 days in a notification (for a click on the bar)
if [ "$1" = "week" ]; then
if ! line=$(ens-forecast --brief 7 2>&1); then
notify-send "ens-forecast" "$line"
exit
fi
body=""
while IFS= read -r part; do
read -r day temps rain extra <<< "$part"
temps=${temps%°C}
body+="$day ${temps%/*}° / ${temps#*/}° rain $rain${extra:+ $extra}"$'\n'
done <<< "$(sed "s/ | /\n/g" <<< "${line#*: }")"
notify-send "${line%%: *}" "${body%$'\n'}"
exit
fi
line=$(ens-forecast --brief 1 2>/dev/null) || exit 0
read -r day temps rain <<< "${line#*: }"
echo "$day ${temps%C} "$'\uf043'" $rain"