From b3614321da36c7124f76ecde9aa18a590e684ddb Mon Sep 17 00:00:00 2001 From: Gavin Inglis Date: Tue, 7 Apr 2020 15:53:34 -0400 Subject: [PATCH] add support for linux network --- scripts/network.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/network.sh b/scripts/network.sh index 0076f86..3666514 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -7,11 +7,32 @@ get_ssid() { - if /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2 &> /dev/null; then - echo "$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2)" - else - echo ' Ethernet' - fi + # Check OS + case $(uname -s) in + Linux) + if iw dev | grep ssid | cut -d ' ' -f 2 &> /dev/null; then + echo $(iw dev | grep ssid | cut -d ' ' -f 2) + else + echo ' Ethernet' + fi + ;; + + Darwin) + if /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2 &> /dev/null; then + echo "$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2)" + else + echo ' Ethernet' + fi + ;; + + CYGWIN*|MINGW32*|MSYS*|MINGW*) + # leaving empty - TODO - windows compatability + ;; + + *) + ;; + esac + } main()