vicious/widgets/cpufreq_freebsd.lua

41 lines
1003 B
Lua
Raw Normal View History

2017-01-25 17:49:37 +01:00
-- {{{ Grab environment
local tonumber = tonumber
local helpers = require("vicious.helpers")
-- }}}
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
-- vicious.widgets.cpufreq
local cpufreq_freebsd = {}
-- {{{ CPU frequency widget type
function cpufreq_freebsd.async(format, warg, callback)
if not warg then return callback({}) end
2017-01-25 17:49:37 +01:00
-- Default frequency and voltage values
local freqv = {
["mhz"] = "N/A", ["ghz"] = "N/A",
["v"] = "N/A", ["mv"] = "N/A",
["governor"] = "N/A",
2017-01-25 17:49:37 +01:00
}
helpers.sysctl_async(
{ "dev.cpu." .. warg .. ".freq" },
function (ret)
freqv.mhz = tonumber(ret["dev.cpu." .. warg .. ".freq"])
freqv.ghz = freqv.mhz / 1000
return callback({
freqv.mhz,
freqv.ghz,
freqv.mv,
freqv.v,
freqv.governor
})
end)
2017-01-25 17:49:37 +01:00
end
-- }}}
return helpers.setasyncall(cpufreq_freebsd)