Skip to content

Commit cac64d6

Browse files
committed
mac: Fix network detection
There air wifi networks that are not compatible with AirPort. In such a case the network.sh script does not detect correctly the SSID. The message reported is: "You are not associated with an AirPort network." Fix the script detecting correctly the SSID of networks that do not support AirPort.
1 parent 9367a04 commit cac64d6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/network.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ get_ssid()
2424
;;
2525

2626
Darwin)
27-
if networksetup -getairportnetwork en0 | cut -d ':' -f 2 | sed 's/^[[:blank:]]*//g' &> /dev/null; then
28-
echo "$wifi_label$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)" | sed 's/^[[:blank:]]*//g'
27+
local wifi_network=$(ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}')
28+
local airport=$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)
29+
30+
if [[ $airport != "You are not associated with an AirPort network." ]]; then
31+
echo "$wifi_label$airport" | sed 's/^[[:blank:]]*//g'
32+
elif [[ $wifi_network != "" ]]; then
33+
echo "$wifi_label$wifi_network" | sed 's/^[[:blank:]]*//g'
2934
else
3035
echo "$ethernet_label"
3136
fi

0 commit comments

Comments
 (0)