diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2017-09-07 17:27:24 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2017-09-07 18:47:10 +0200 |
| commit | 5a5f1fccb87df34e3019631b56882bfe9a041291 (patch) | |
| tree | e2386617359515ef2c3eca3a357667c172f7acc2 /awesome/rc.lua | |
| parent | 9ae23fb27a49f877ab463bb9e883897a74db70e4 (diff) | |
awesome: simplify format string generation of cpu widget
Diffstat (limited to 'awesome/rc.lua')
| -rw-r--r-- | awesome/rc.lua | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/awesome/rc.lua b/awesome/rc.lua index 5af88d9..1288238 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -172,26 +172,16 @@ for bat = 0, 1 do end end -function cpu_string() - local f = io.open("/proc/cpuinfo", "r") - local n = 2 - local result = " CPU:$2%" - if f then - f:read() -- skip first line/processor - for line in f:lines() do - m = string.match(line, "processor\t*: %d+") - if m then - n = n + 1 - result = result .. "/$" .. n .. "%" - end - end - f:close() +function cpu_string(widget, loads) + local result = " CPU:" .. loads[1] .. "%" + for cpu = 2, #loads-1 do + result = result .. "/" .. loads[cpu] .. "%" end return result .. " " end cpuwidget = wibox.widget.textbox() -vicious.register(cpuwidget, vicious.widgets.cpu, cpu_string(), 2) +vicious.register(cpuwidget, vicious.widgets.cpu, cpu_string, 2) -- Create a wibox for each screen and add it local taglist_buttons = awful.util.table.join( |
