From 6bf79c30ae94457cc76061c037c7453169ebf3ca Mon Sep 17 00:00:00 2001 From: Pratik Devkota <64492098+pratik-devkota@users.noreply.github.com> Date: Thu, 1 Jul 2021 19:07:07 +0000 Subject: [PATCH] Update cpu.lua (#506) I noticed once that the CPU usage was being reported as being '-1%', I dug around the code for a while and think that the change at line 52 should make sure no negative values are obtained. Co-authored-by: Pratik Devkota --- widget/cpu.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/cpu.lua b/widget/cpu.lua index c2e28b0..6c51115 100644 --- a/widget/cpu.lua +++ b/widget/cpu.lua @@ -49,7 +49,7 @@ local function factory(args) -- Read current data and calculate relative values. local dactive = active - core.last_active local dtotal = total - core.last_total - local usage = math.ceil((dactive / dtotal) * 100) + local usage = math.ceil(math.abs((dactive / dtotal) * 100)) core.last_active = active core.last_total = total