From 5de546c3c4f2b2a6be5320680c89dc8fcdb72ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9C=A4=EA=B8=B0?= Date: Sun, 28 Jun 2026 21:22:54 +0900 Subject: [PATCH] fix(network): don't show a saved SSID when Wi-Fi is disconnected on macOS `scripts/network.sh` derives `wifi_network` from `networksetup -listpreferredwirelessnetworks`, which lists saved/preferred networks rather than the current association. When Wi-Fi is off but the host is online via Ethernet, `getairportnetwork` reports "not associated" and the module falls back to the first saved network, displaying a stale SSID (e.g. an old phone hotspot) the machine is not connected to. Gate the Wi-Fi branch on the interface actually being associated (`ifconfig "$ifname"` -> `status: active`) before consulting any SSID source. A not-associated interface now reports the Ethernet/Offline label. The #370 connected-Wi-Fi SSID resolution is left untouched, so there is no regression for users currently on Wi-Fi. Fixes #396 Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/network.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/network.sh b/scripts/network.sh index bbcfb485..d57c12d4 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -41,6 +41,16 @@ get_ssid() ifname=$(_get_wifi_ifname) + # Only report a Wi-Fi network when the interface is actually associated. Otherwise the + # fallback below can surface a saved/preferred SSID (listpreferredwirelessnetworks) and + # show a stale name -- e.g. an old hotspot -- whenever Wi-Fi is off but the machine is + # online via Ethernet. Association state stays readable even though the SSID itself is + # gated behind Location Services on macOS 15+. + if [[ "$(ifconfig "$ifname" 2>/dev/null | awk '/status:/ {print $2}')" != "active" ]]; then + echo "$ethernet_label" + return + fi + # string manipulation required to remove the minor version of the macos version (e.g. x.y.z removes .z) # this is required to prevent issues in version detection #