[PR] #56 from leana8959: Fix macOS network detection
Fix network module on macOS
This commit is contained in:
commit
14c7963d88
1 changed files with 10 additions and 0 deletions
10
neofetch
10
neofetch
|
@ -3286,6 +3286,16 @@ get_network() {
|
||||||
fi
|
fi
|
||||||
done < <(find /sys/class/net/ -type l)
|
done < <(find /sys/class/net/ -type l)
|
||||||
;;
|
;;
|
||||||
|
"Mac OS X"|"macOS")
|
||||||
|
ActiveNetwork=$(route get default | grep interface | awk '{print $2}')
|
||||||
|
ActiveNetworkName=$(networksetup -listallhardwareports | grep -B 1 "$ActiveNetwork" | awk '/Hardware Port/{print}'| awk '{print $3}')
|
||||||
|
if [[ $ActiveNetworkName == "Wi-Fi" ]]; then
|
||||||
|
LinkSpeed="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/maxRate/{print}' | awk '{print $2}' )Mbps"
|
||||||
|
else
|
||||||
|
LinkSpeed="$(ifconfig "$ActiveNetwork" | awk '/media/{print}' | sed -E "s/.*\((.*)\).*/\1/")"
|
||||||
|
fi
|
||||||
|
network="$ActiveNetwork: $ActiveNetworkName@$LinkSpeed"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
while IFS=' ' read -r n i; do
|
while IFS=' ' read -r n i; do
|
||||||
if [ -n "$i" ]; then
|
if [ -n "$i" ]; then
|
||||||
|
|
Loading…
Reference in a new issue