diff options
Diffstat (limited to 'bspwm')
-rwxr-xr-x | bspwm/panel | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/bspwm/panel b/bspwm/panel index a16448d..24bf33a 100755 --- a/bspwm/panel +++ b/bspwm/panel @@ -59,28 +59,38 @@ done & # Network throughput while :; do - net_info=$( - ip -4 -o addr show | grep -v ' lo ' | - while read line; do - iface=$(echo $line | cut -d ' ' -f 2); - addr=$(echo $line | cut -d ' ' -f 4 | sed 's/\/.*//'); + net_info=$( + ip -4 -o addr show | grep -v ' lo ' | + while read line; do + iface=$(echo $line | cut -d ' ' -f 2); + # addr=$(echo $line | cut -d ' ' -f 4 | sed 's/\/.*//'); - rf=/sys/class/net/eth0/statistics/rx_bytes; - tf=/sys/class/net/eth0/statistics/tx_bytes; + if [ ! -d /sys/class/net/$iface ]; then + sleep 1; + continue; + fi - # Get RX and TX bytes then sleep for ~1 second - r1=`cat $rf`; - t1=`cat $tf`; - sleep 1 + rf=/sys/class/net/$iface/statistics/rx_bytes; + tf=/sys/class/net/$iface/statistics/tx_bytes; - # Get RX and TX bytes and print rates in KBPS - r2=`cat $rf`; - t2=`cat $tf`; - rr="$(((r2-r1)/1024))"; - tr="$(((t2-t1)/1024))"; - printf "$iface $addr %04.0f↓ %04.0f↑ " $rr $tr - done) - echo "N$net_info" > "$PANEL_FIFO" + # Get RX and TX bytes then sleep for ~1 second + r1=`cat $rf`; + t1=`cat $tf`; + sleep 1 + + # Get RX and TX bytes and print rates in KBPS + r2=`cat $rf`; + t2=`cat $tf`; + rr="$(((r2-r1)/1024))"; + tr="$(((t2-t1)/1024))"; + # printf "$iface $addr %04.0f↓ %04.0f↑ " $rr $tr + printf "$iface %04.0f↓ %04.0f↑ " $rr $tr + done) + if [ -z "$net_info" ]; then + sleep 5; + else + echo "N$net_info" > "$PANEL_FIFO" + fi done & #. ./panel_colors |