diff --git a/modules/home/waybar.nix b/modules/home/waybar.nix index bf26257..cedcd56 100644 --- a/modules/home/waybar.nix +++ b/modules/home/waybar.nix @@ -107,15 +107,20 @@ let # VPN indicator — shows a shield when a NetworkManager VPN/WireGuard # connection is active OR Tailscale is up; prints nothing otherwise so the - # module self-hides (like nightlight/updates). Click opens the VPN submenu. + # module self-hides (like nightlight/updates). The tooltip names each + # active VPN (NM connection names, "Tailscale") — without it a forgotten + # tailscaled reads as "the icon is stuck". Click opens the VPN submenu. vpnStatus = pkgs.writeShellScriptBin "nomarchy-vpn-status" '' - active=$(nmcli -t -f TYPE connection show --active 2>/dev/null | grep -Exm1 'vpn|wireguard') + names=$(nmcli -t -f NAME,TYPE connection show --active 2>/dev/null \ + | awk -F: '$2=="vpn"||$2=="wireguard"{print $1}') ts="" if command -v tailscale >/dev/null 2>&1; then - [ "$(tailscale status --json 2>/dev/null | jq -r '.BackendState // empty')" = Running ] && ts=1 + [ "$(tailscale status --json 2>/dev/null | jq -r '.BackendState // empty')" = Running ] && ts=Tailscale fi - [ -n "$active" ] || [ -n "$ts" ] || exit 0 - printf '{"text":"󰦝","tooltip":"VPN active (click to manage)","class":"on"}\n' + [ -n "$names$ts" ] || exit 0 + list=$(printf '%s\n' "$names" "$ts" | grep -v '^$' | paste -sd ', ' -) + tip=$(printf 'VPN: %s\n(click to manage)' "$list" | jq -Rs 'rtrimstr("\n")') + printf '{"text":"󰦝","tooltip":%s,"class":"on"}\n' "$tip" ''; # Health warning — self-gates: prints nothing while nomarchy-doctor