diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2015-01-31 23:37:11 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2015-01-31 23:37:11 +0100 |
| commit | 3a8967e4192323980c89e6f200e60c191a125538 (patch) | |
| tree | afe9e2e111da30ac8ff0a83eabeb1fcde3d7a738 /awesome/rc.lua | |
| parent | 33a6f2d1fd1de171104beadd38a902712a22ef9d (diff) | |
awesome: calculate cpu string dynamically
Diffstat (limited to 'awesome/rc.lua')
| -rw-r--r-- | awesome/rc.lua | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/awesome/rc.lua b/awesome/rc.lua index 178bbcb..72f421a 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -140,8 +140,26 @@ 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() + end + return result .. " " +end + cpuwidget = widget({ type = 'textbox', name = 'cpuwidget', align = 'right' }) -vicious.register(cpuwidget, vicious.widgets.cpu, ' CPU:$2%/$3%/$4%/$5% ', 2) +vicious.register(cpuwidget, vicious.widgets.cpu, cpu_string(), 2) -- Create a systray mysystray = widget({ type = "systray" }) |
