mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
improve speed format
Convert network speed into human-readable format using numfmt, this will handle low and high values properly.
This commit is contained in:
parent
be9490155f
commit
ed3e85ce11
@ -19,10 +19,10 @@ update() {
|
||||
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
||||
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
||||
printf %d\\n "$sum" > "$cache"
|
||||
printf %d\\n $(( (sum - old) / 1024 ))
|
||||
printf %d\\n $(( sum - old ))
|
||||
}
|
||||
|
||||
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
||||
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
||||
|
||||
printf "🔻%dKiB 🔺%dKiB\\n" "$rx" "$tx"
|
||||
printf "🔻%sB 🔺%sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec-i $tx)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user