dotfiles/eww/scripts/tx_bandwidth.sh
2024-08-26 11:05:11 -04:00

18 lines
350 B
Bash
Executable File

#!/bin/bash
DEV=`nmcli d | grep -P "[^(dis)]connected [^(\(externally\))]" | grep -Po ".*?(?= )" | head -n1`
TX_BYTES=$(cat /sys/class/net/$DEV/statistics/tx_bytes)
TX_KB=`expr $TX_BYTES / 1024`
TX_MB=`expr $TX_KB / 1024`
if [ $TX_MB -ge 1 ]
then
echo $TX_MB mB/s
elif [ $TX_KB -ge 1 ]
then
echo $TX_KB kB/s
else
echo $TX_BYTES B/s
fi