Skip to content

Commit

Permalink
[PR] #56 from leana8959: Fix macOS network detection
Browse files Browse the repository at this point in the history
Fix network module on macOS
  • Loading branch information
hykilpikonna committed Dec 24, 2022
2 parents 1c2cee4 + c694073 commit 14c7963
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -3286,6 +3286,16 @@ get_network() {
fi
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
while IFS=' ' read -r n i; do
if [ -n "$i" ]; then
Expand Down

0 comments on commit 14c7963

Please sign in to comment.