Talk:CPU Usage

i adapted this widget for awesome 3.5 as best i could as the original syntax wasn't working. at the very least, the awful.hooks.timer function is deprecated. anyway, i'm not totally sure how the whole updating a wiki page thing works or if this should be a new one altogether, but this is the code i finished with:

-- -- {{ function jiffies = {} function activecpu cpusage = "" for line in io.lines("/proc/stat") do               local cpu, newjiffies = string.match(line, "(cpu%d*)%s+(%d+)") if cpu and newjiffies then if not jiffies[cpu] then jiffies[cpu] = newjiffies end --The string.format prevents your task list from jumping around --when CPU usage goes above/below 10% cpusage = cpusage .. "." .. string.format("%02d", newjiffies-jiffies[cpu]) jiffies[cpu] = newjiffies end end cpuwidget:set_markup(cpusage) end

and to call it in rc.lua using the new timer function

cpu_timer = timer({timeout = 1}) cpu_timer:connect_signal("timeout", function activecpu end) cpu_timer:start

i did change the resulting string format a bit too, it now prints ##.##.##... i did this because with 5 cores the original syntax took up a lot of space.