Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network module on macOS #56

Merged
merged 7 commits into from
Dec 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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