From f11008c619e1746d0d3f25c471343c1591200941 Mon Sep 17 00:00:00 2001 From: jamazi <31401744+jamazi@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:59:54 +0300 Subject: [PATCH] improve speed format (#738) * improve speed format Convert network speed into human-readable format using numfmt, this will handle low and high values properly. * Update nettraf fix jitter --- .local/bin/statusbar/nettraf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index ac43416..af61d5a 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -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 "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec-i $tx)