diff options
Diffstat (limited to 'dwmbar/bar_net_activity.sh')
-rwxr-xr-x | dwmbar/bar_net_activity.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/dwmbar/bar_net_activity.sh b/dwmbar/bar_net_activity.sh new file mode 100755 index 0000000..f08fb4f --- /dev/null +++ b/dwmbar/bar_net_activity.sh @@ -0,0 +1,30 @@ + +# network activity + +[ ! -f /tmp/netactup ] || touch /tmp/netactup +[ ! -f /tmp/netactdown ] || touch /tmp/netactdown + +# get previous results +rx_prev=$(cat /tmp/netactdown) +tx_prev=$(cat /tmp/netactup) + +# convert results to integers +rx_prev=$(($rx_prev)) +tx_prev=$(($tx_prev)) + +# set variables to sys files +rx_now=$(cat /sys/class/net/enp60s0/statistics/rx_bytes) +tx_now=$(cat /sys/class/net/enp60s0/statistics/tx_bytes) + +# convert variables to integers +rx_now=$(($rx_now)) +tx_now=$(($tx_now)) + +# caculate amount send and recieved +down_total=$((rx_now - rx_prev)) +up_total=$((tx_now - tx_prev)) + +echo $rx_now > /tmp/netactdown +echo $tx_now > /tmp/netactup + +echo "D:" $(numfmt --to=iec $down_total) "U:" $(numfmt --to=iec $up_total) |