Skip to content

Commit

Permalink
Ethernet name can have spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodalgaard committed Nov 21, 2021
1 parent d2c3724 commit e292482
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ethernet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ "$(getEthernetState "$INTERFACE")" == 0 ]; then
fi

# Get network configuration
NETINFO=$(networksetup -getinfo Ethernet)
NETINFO=$(networksetup -getinfo "$NAME")
NETCONFIG=$(getConnectionConfig "$NETINFO")

MAC=$(getEthernetMac)
Expand Down Expand Up @@ -49,7 +49,7 @@ if [ "$VPN" != "" ]; then
fi

# Output DNS list
DNSSTRING=$(getDNS "$(networksetup -getdnsservers Ethernet)")
DNSSTRING=$(getDNS "$(networksetup -getdnsservers "$NAME")")
if [ "$DNSSTRING" != "" ]; then
addResult "" "$DNSSTRING" "$DNSSTRING" "DNS list" "$ICON_ETH"
fi
Expand Down
15 changes: 9 additions & 6 deletions src/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
. src/workflowHandler.sh
. src/media.sh

ETHERNET_REGEX="LAN$|Lan$|Ethernet$"
WIFI_REGEX="Airport$|Wi-Fi$"

PRIORITY_HIGH="1"
PRIORITY_MEDIUM="2"
PRIORITY_LOW="5"
Expand Down Expand Up @@ -39,37 +42,37 @@ getEthernetState() {

getWifiName() {
local LIST=${1-$(networksetup -listallhardwareports)}
local DETAILS=$(echo "$LIST" | grep -A 2 -E "Airport$|Wi-Fi$")
local DETAILS=$(echo "$LIST" | grep -A 2 -E "$WIFI_REGEX")
echo "$DETAILS" | grep -Eo "AirPort|Wi-Fi"
}

getEthernetName() {
local LIST=${1-$(networksetup -listallhardwareports)}
local DETAILS=$(echo "$LIST" | grep -A 2 -E "Ethernet$")
local DETAILS=$(echo "$LIST" | grep -A 2 -E "$ETHERNET_REGEX")
echo "$DETAILS" | awk '/Hardware / {print substr($0, index($0, $3))}'
}

getWifiInterface() {
local LIST=${1-$(networksetup -listallhardwareports)}
local DETAILS=$(echo "$LIST" | grep -A 2 -E "Airport$|Wi-Fi$")
local DETAILS=$(echo "$LIST" | grep -A 2 -E "$WIFI_REGEX")
echo "$DETAILS" | grep -m 1 -o -e en[0-9]
}

getEthernetInterface() {
local LIST=${1-$(networksetup -listallhardwareports)}
local DETAILS=$(echo "$LIST" | grep -A 2 -E "LAN$|Ethernet$")
local DETAILS=$(echo "$LIST" | grep -A 2 -E "$ETHERNET_REGEX")
echo "$DETAILS" | grep -m 1 -o -e en[0-9]
}

getWifiMac() {
local LIST=${1-$(networksetup -listallhardwareports)}
local DETAILS=$(echo "$LIST" | grep -A 2 -E "Airport$|Wi-Fi$")
local DETAILS=$(echo "$LIST" | grep -A 2 -E "$WIFI_REGEX")
echo "$DETAILS" | awk '/Ethernet Address: / {print substr($0, index($0, $3))}'
}

getEthernetMac() {
local LIST=${1-$(networksetup -listallhardwareports)}
local DETAILS=$(echo "$LIST" | grep -A 2 -E "Ethernet$")
local DETAILS=$(echo "$LIST" | grep -A 2 -E "$ETHERNET_REGEX")
echo "$DETAILS" | awk '/Ethernet Address: / {print substr($0, index($0, $3))}'
}

Expand Down

0 comments on commit e292482

Please sign in to comment.