From 3643275e4414cd7f182b67f3e9dbbd4a08130ad7 Mon Sep 17 00:00:00 2001 From: b1f6c1c4 Date: Thu, 23 Jul 2020 22:55:53 -0400 Subject: [PATCH] network speed support for linux --- neofetch | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/neofetch b/neofetch index f31996d4..4f195155 100755 --- a/neofetch +++ b/neofetch @@ -73,6 +73,7 @@ print_info() { info "CPU" cpu info "GPU" gpu info "Memory" memory + info "Network" network # info "GPU Driver" gpu_driver # Linux/macOS only # info "CPU Usage" cpu_usage @@ -2648,6 +2649,45 @@ get_memory() { esac } +get_network() { + case $os in + "Linux") + while IFS= read -r i; do + # List all operational, physical devices + if [ "$(cat "$i/operstate")" = "up" ] && [ -e "$i/device" ]; then + if [ ! -e "$i/phy80211" ]; then + networks+="$(cat "$i/speed")" + else + networks+="Wifi" + fi + networks+=$'\n' + fi + done < <(find /sys/class/net/ -type l) + ;; + esac + while IFS=' ' read -r n i; do + if [ -n "$i" ]; then + [ "$n" -gt 1 ] && network+="${n}x " + if [ "$i" = "Wifi" ]; then + network+="Wifi; " + elif [ "$i" = "-1" ]; then + network+="Unknown; " + elif [ "${i%000}" = "$i" ]; then + network+="$i Mbps; " + elif [ "$i" = "2500" ]; then + network+="2.5 Gbps; " + else + network+="${i%000} Gbps; " + fi + fi + done < <(sort -rn <<<"$networks" | uniq -c) + if [ -z "$network" ]; then + network="None" + else + network="${network%; }" + fi +} + get_song() { players=( "amarok" @@ -5192,6 +5232,7 @@ get_args() { info "GPU" gpu info "GPU Driver" gpu_driver info "Memory" memory + info "Network" network info "CPU Usage" cpu_usage info "Disk" disk