mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Update nettraf
This commit is contained in:
parent
93328fb1b3
commit
33b6448341
@ -10,18 +10,6 @@ case "$BLOCK_BUTTON" in
|
|||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
function bytes_for_humans {
|
|
||||||
local -i current_speed="($1-$2)/1024"
|
|
||||||
echo $current_speed;
|
|
||||||
if [[ $bytes -lt 1024 ]]; then
|
|
||||||
echo "${bytes}B"
|
|
||||||
elif [[ $bytes -lt 1048576 ]]; then
|
|
||||||
echo "$(( (bytes + 1023)/1024 ))KiB"
|
|
||||||
else
|
|
||||||
echo "$(( (bytes + 1048575)/1048576 ))MiB"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
rxfile="${XDG_CACHE_HOME:-$HOME/.cache}/rxlog"
|
rxfile="${XDG_CACHE_HOME:-$HOME/.cache}/rxlog"
|
||||||
txfile="${XDG_CACHE_HOME:-$HOME/.cache}/txlog"
|
txfile="${XDG_CACHE_HOME:-$HOME/.cache}/txlog"
|
||||||
|
|
||||||
@ -29,8 +17,8 @@ rxcurrent="$(cat /sys/class/net/*/statistics/rx_bytes | tr '\n' '+' | sed 's/+$/
|
|||||||
txcurrent="$(cat /sys/class/net/*/statistics/tx_bytes | tr '\n' '+' | sed 's/+$/\n/' | bc)"
|
txcurrent="$(cat /sys/class/net/*/statistics/tx_bytes | tr '\n' '+' | sed 's/+$/\n/' | bc)"
|
||||||
|
|
||||||
printf " 🔻%04dKiB 🔺%04dKiB " \
|
printf " 🔻%04dKiB 🔺%04dKiB " \
|
||||||
"$(printf -- "(%s-%s)\\n" "$rxcurrent" "$(cat "$rxfile")" | bytes_for_humans)" \
|
"$(printf -- "(%s-%s)\\n" "$rxcurrent" "$(cat "$rxfile")" | bc )" \
|
||||||
"$(printf -- "(%s-%s)\\n" "$txcurrent" "$(cat "$txfile")" | bytes_for_humans)"
|
"$(printf -- "(%s-%s)\\n" "$txcurrent" "$(cat "$txfile")" | bc )"
|
||||||
|
|
||||||
# Log the current values for next run.
|
# Log the current values for next run.
|
||||||
echo "$rxcurrent" > "$rxfile"
|
echo "$rxcurrent" > "$rxfile"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user