From 2839f87d15cea2d08033f4c843607109dd7e3853 Mon Sep 17 00:00:00 2001 From: Darren Cheng Date: Thu, 12 Dec 2024 16:58:12 -0800 Subject: [PATCH] Patch SSID function. --- cmd/ssid/root.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/cmd/ssid/root.go b/cmd/ssid/root.go index d0911207..0f25b4bf 100644 --- a/cmd/ssid/root.go +++ b/cmd/ssid/root.go @@ -13,25 +13,13 @@ import ( ) func main() { - info := run.Capture("networksetup -getairportnetwork en0") + info := run.Capture("ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}'") - if strings.Contains(info, "Wi-Fi power is currently off") { + if len(info) == 0 { os.Exit(0) } - lines := strings.Split(info, "\n") - - for _, line := range lines { - if strings.Contains(line, "Current Wi-Fi Network: ") { - - ssid := strings.Replace(line, "Current Wi-Fi Network: ", "", 1) - ssid = strings.TrimSpace(ssid) - - printSSID(ssid) - - os.Exit(0) - } - } + printSSID(info) } func printSSID(ssid string) {