Skip to content

Commit

Permalink
Update cpu.lua (#506)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Pratik Devkota and Pratik Devkota authored Jul 1, 2021
1 parent 2e5660f commit 6bf79c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion widget/cpu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6bf79c3

Please sign in to comment.