cpuinf: prepend 'cpu' to CPU ID in table keys
Keys like cpu0 are more suitable, because they match cpufreq widget arguments. Instead of old format strings, like: ${0 mhz} now use: ${cpu0 mhz}
This commit is contained in:
parent
0d5f07b86e
commit
3d97d44a02
11
cpuinf.lua
11
cpuinf.lua
|
@ -16,10 +16,9 @@ module("vicious.cpuinf")
|
||||||
|
|
||||||
-- {{{ CPU Information widget type
|
-- {{{ CPU Information widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
cpu_id = nil
|
|
||||||
|
|
||||||
-- Get cpuinfo
|
-- Get cpuinfo
|
||||||
local f = io.open("/proc/cpuinfo")
|
local f = io.open("/proc/cpuinfo")
|
||||||
|
local cpu_id = nil
|
||||||
local cpu_info = {}
|
local cpu_info = {}
|
||||||
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
|
@ -27,12 +26,12 @@ local function worker(format)
|
||||||
cpu_id = line:match("([%d]+)")
|
cpu_id = line:match("([%d]+)")
|
||||||
elseif line:match("^cpu MHz.*") then
|
elseif line:match("^cpu MHz.*") then
|
||||||
local cpu_speed = line:match("([%d]+)%.")
|
local cpu_speed = line:match("([%d]+)%.")
|
||||||
cpu_info["{"..cpu_id.." mhz}"] = cpu_speed
|
cpu_info["{cpu"..cpu_id.." mhz}"] = cpu_speed
|
||||||
cpu_info["{"..cpu_id.." ghz}"] = tonumber(cpu_speed) / 1000
|
cpu_info["{cpu"..cpu_id.." ghz}"] = tonumber(cpu_speed) / 1000
|
||||||
elseif line:match("^cache size.*") then
|
elseif line:match("^cache size.*") then
|
||||||
local cpu_cache = line:match("([%d]+)[%s]KB")
|
local cpu_cache = line:match("([%d]+)[%s]KB")
|
||||||
cpu_info["{"..cpu_id.." kb}"] = cpu_cache
|
cpu_info["{cpu"..cpu_id.." kb}"] = cpu_cache
|
||||||
cpu_info["{"..cpu_id.." mb}"] = tonumber(cpu_cache) / 1024
|
cpu_info["{cpu"..cpu_id.." mb}"] = tonumber(cpu_cache) / 1024
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
|
Loading…
Reference in New Issue