diff options
-rwxr-xr-x | dwm-statusbar | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/dwm-statusbar b/dwm-statusbar index 69b9734..2b6e854 100755 --- a/dwm-statusbar +++ b/dwm-statusbar @@ -214,12 +214,23 @@ print_cpu_used() { # Configure the adapter to display above print_eth() { - icon_colour=${colour_neutral} - eth_colour=${colour_normal} - ips=($(ip -oneline addr show up | awk 'match($0, /.+enp.*inet ([0-9.]+)\/.*/, cap) {print cap[1]}')) + devices=($(ip -oneline addr show up | ip -oneline addr show up | awk 'match($0, /.+(enp.*?) inet ([0-9.]+)\/.*/, cap) {print cap[1]}')) - for eth_ip in $ips; do - echo -ne "${space}${icon_colour}\uE0E4${eth_colour}${eth_ip}" + for dev in $devices; do + ip=$(ip -oneline addr show dev $dev | awk 'match($0, /.+enp.*inet ([0-9.]+)\/.*/, cap) {print cap[1]}') + speed=$(ethtool $dev &> /dev/null | awk 'match($0, / *Speed: ([0-9A-z/]+).*/, cap) {print cap[1]}') + + if [[ $speed == "10Mb/s" ]]; then + icon_colour=${colour_critical} + eth_colour=${colour_critical} + elif [[ $speed == "100Mb/s" ]]; then + icon_colour=${colour_warning} + eth_colour=${colour_warning} + else + icon_colour=${colour_neutral} + eth_colour=${colour_normal} + fi + echo -ne "${space}${icon_colour}\uE0E4${eth_colour}${ip} ${speed}" done } |