Skip to content

Commit

Permalink
Patch SSID function.
Browse files Browse the repository at this point in the history
  • Loading branch information
drn committed Dec 13, 2024
1 parent c05cddd commit 2839f87
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions cmd/ssid/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2839f87

Please sign in to comment.