14 lines
478 B
Bash
Executable file
14 lines
478 B
Bash
Executable file
#!/bin/sh
|
|
# Modified version of Luke Smith's network usage script
|
|
|
|
# Print cache so it doesn't get stuck in dwmblocks
|
|
cat "$XDG_CACHE_HOME"/netstat-dow
|
|
|
|
# Store recieved bytes
|
|
start="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
|
|
sleep 1
|
|
end="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
|
|
|
|
# Format correctly and print
|
|
load=$(numfmt --to=iec $(($end-$start)))
|
|
printf "%2sB/s\n" $load | sed 's/ //g' > "$XDG_CACHE_HOME"/netstat-dow
|