Files
dotfiles/.config/xmobar/ens_brief.sh
T

23 lines
792 B
Bash
Executable File

#!/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"