xmobar: show current weather details on click

Clicking the weather now runs weather.sh notify, which shows the
description and temperature; the forecast keeps its ens-forecast week
notification.
This commit is contained in:
Daniele Fucini committed 2026-11-12 19:24:15 +01:00
1 parent 0d1cb6cf2a
commit 472bf7246b
3 files changed
+14 -4

No files matched your search

+12 -2
View File
@@ -2,6 +2,7 @@
# Current weather for xmobar, e.g. "<icon> 7°C": NOAA's decoded METAR (the source of xmobar's Weather plugin) # Current weather for xmobar, e.g. "<icon> 7°C": NOAA's decoded METAR (the source of xmobar's Weather plugin)
# Icon from the weather, else the sky conditions; clear/partly/mostly cloudy get moon icons when the sun is down. # Icon from the weather, else the sky conditions; clear/partly/mostly cloudy get moon icons when the sun is down.
# Temperature colors match the plugin's -L 0 -H 30: low up to 0, high above 30. # Temperature colors match the plugin's -L 0 -H 30: low up to 0, high above 30.
# With "notify": show the description (e.g. "Light drizzle, mist") and temperature in a notification instead.
STATION=LZIB LAT=48.2 LON=17.2 STATION=LZIB LAT=48.2 LON=17.2
@@ -17,12 +18,12 @@ declare -A ICON=(
report=$(curl -sf --max-time 20 https://tgftp.nws.noaa.gov/data/observations/metar/decoded/"$STATION".TXT) report=$(curl -sf --max-time 20 https://tgftp.nws.noaa.gov/data/observations/metar/decoded/"$STATION".TXT)
temp=$(sed -n 's/^Temperature: .*(\([-0-9.]*\) C).*/\1/p' <<< "$report") temp=$(sed -n 's/^Temperature: .*(\([-0-9.]*\) C).*/\1/p' <<< "$report")
if [[ -z $temp ]]; then if [[ -z $temp ]]; then
echo "${ICON[thermometer]} N/A" if [[ $1 == notify ]]; then notify-send "Weather" "No report from $STATION"; else echo "${ICON[thermometer]} N/A"; fi
exit 0 exit 0
fi fi
# Phenomena "in the vicinity" aren't at the station; the rest are e.g. "light drizzle; mist" # Phenomena "in the vicinity" aren't at the station; the rest are e.g. "light drizzle; mist"
wx=$(sed -n 's/^Weather: //p' <<< "$report" | tr ';' '\n' | grep -v vicinity | tr '\n' ' ') wx=$(sed -n 's/^Weather: //p' <<< "$report" | tr ';' '\n' | sed 's/^ *//' | grep -v vicinity)
wx=${wx,,} wx=${wx,,}
sky=$(sed -n 's/^Sky conditions: //p' <<< "$report") sky=$(sed -n 's/^Sky conditions: //p' <<< "$report")
sky=${sky,,} sky=${sky,,}
@@ -66,4 +67,13 @@ if awk -v t="$temp" 'BEGIN { exit !(t > 30) }'; then color="#ffb86c"
elif awk -v t="$temp" 'BEGIN { exit !(t > 0) }'; then color="#50fa7b" elif awk -v t="$temp" 'BEGIN { exit !(t > 0) }'; then color="#50fa7b"
else color="#8be9fd" else color="#8be9fd"
fi fi
if [[ $1 == notify ]]; then
if [[ -n $wx ]]; then desc=$(paste -sd, <<< "$wx" | sed 's/,/, /g')
elif [[ $icon == day_sunny ]]; then desc=sunny
else desc=${sky:-unknown}
fi
notify-send "${ICON[$icon]} Weather" "${desc^}, $temp°C"
exit 0
fi
echo "${ICON[$icon]} <fc=$color>$temp</fc>°C" echo "${ICON[$icon]} <fc=$color>$temp</fc>°C"
+1 -1
View File
@@ -48,5 +48,5 @@ Config { overrideRedirect = True
] ]
, sepChar = "%" , sepChar = "%"
, alignSep = "}{" , alignSep = "}{"
, template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%weather% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | %date% " , template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | %pactl_volume% | %date% "
} }
+1 -1
View File
@@ -49,5 +49,5 @@ Config { overrideRedirect = True
] ]
, sepChar = "%" , sepChar = "%"
, alignSep = "}{" , alignSep = "}{"
, template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%weather% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | %date% %_XMONAD_TRAYPAD% " , template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | %pactl_volume% | %date% %_XMONAD_TRAYPAD% "
} }