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
|
2019-07-31 18:22:49 +02:00
|
|
|
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",
|
2019-07-31 18:22:49 +02:00
|
|
|
["governor"] = "N/A",
|
2017-01-25 17:49:37 +01:00
|
|
|
}
|
|
|
|
|
2019-07-31 18:22:49 +02:00
|
|
|
helpers.sysctl_async({ "dev.cpu." .. warg .. ".freq" }, function(ret)
|
|
|
|
freqv.mhz = tonumber(ret["dev.cpu." .. warg .. ".freq"])
|
|
|
|
freqv.ghz = freqv.mhz / 1000
|
2017-01-25 17:49:37 +01:00
|
|
|
|
2019-07-31 18:22:49 +02:00
|
|
|
return callback({freqv.mhz, freqv.ghz, freqv.mv, freqv.v, freqv.governor})
|
|
|
|
end)
|
2017-01-25 17:49:37 +01:00
|
|
|
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2019-07-31 18:22:49 +02:00
|
|
|
return helpers.setasyncall(cpufreq_freebsd)
|