From d1c047c78a647d0703785303c1ded6fb24ae0127 Mon Sep 17 00:00:00 2001 From: zachir Date: Wed, 15 Mar 2023 01:37:37 -0500 Subject: make net widget use bytes, not bits --- net-speed-widget/net-speed.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/net-speed-widget/net-speed.lua b/net-speed-widget/net-speed.lua index daa218a..c0d709e 100644 --- a/net-speed-widget/net-speed.lua +++ b/net-speed-widget/net-speed.lua @@ -20,21 +20,21 @@ local net_speed_widget = {} local function convert_to_h(bytes) local speed local dim - local bits = bytes * 8 - if bits < 1000 then - speed = bits + local l_bytes = bytes + if l_bytes < 1000 then + speed = l_bytes dim = 'b' - elseif bits < 1000000 then - speed = bits/1000 + elseif l_bytes < 1000000 then + speed = l_bytes/1000 dim = 'k' - elseif bits < 1000000000 then - speed = bits/1000000 + elseif l_bytes < 1000000000 then + speed = l_bytes/1000000 dim = 'm' - elseif bits < 1000000000000 then - speed = bits/1000000000 + elseif l_bytes < 1000000000000 then + speed = l_bytes/1000000000 dim = 'g' else - speed = tonumber(bits) + speed = tonumber(l_bytes) dim = 'b' end return math.floor(speed + 0.5) .. dim -- cgit v1.2.3