port cpufreq widget to freebsd
This commit is contained in:
parent
d7c99133e1
commit
fbd91c9b37
|
@ -0,0 +1,34 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
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
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
-- Default frequency and voltage values
|
||||||
|
local freqv = {
|
||||||
|
["mhz"] = "N/A", ["ghz"] = "N/A",
|
||||||
|
["v"] = "N/A", ["mv"] = "N/A",
|
||||||
|
}
|
||||||
|
|
||||||
|
local freq = tonumber(helpers.sysctl("dev.cpu." .. warg .. ".freq"))
|
||||||
|
|
||||||
|
freqv.mhz = freq
|
||||||
|
freqv.ghz = freq / 1000
|
||||||
|
|
||||||
|
local governor = "N/A"
|
||||||
|
|
||||||
|
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(cpufreq_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
||||||
-- vicious.widgets.cpufreq
|
-- vicious.widgets.cpufreq
|
||||||
local cpufreq = {}
|
local cpufreq_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
-- {{{ CPU frequency widget type
|
||||||
|
@ -58,4 +58,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpufreq, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end })
|
Loading…
Reference in New Issue