diff options
author | Eddy Pedroni <epedroni@pm.me> | 2025-07-29 19:59:59 +0200 |
---|---|---|
committer | Eddy Pedroni <epedroni@pm.me> | 2025-07-29 19:59:59 +0200 |
commit | 6fa286927847c7ac7b3095bbd4064028c6fb1b44 (patch) | |
tree | b0ebb0ed7bd4493f9b0f232f4739efc7952136a1 | |
parent | 848e0c573c3b4cf6553e06c9ce19560a4b003bcf (diff) |
Ethernet speed in statusbar
-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 } |