port cpufreq widget to freebsd

This commit is contained in:
mutlusun 2017-01-25 17:49:37 +01:00 committed by Jörg Thalheim
parent d7c99133e1
commit fbd91c9b37
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
2 changed files with 36 additions and 2 deletions

View File

@ -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 })

View File

@ -13,7 +13,7 @@ local helpers = require("vicious.helpers")
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
-- vicious.widgets.cpufreq
local cpufreq = {}
local cpufreq_linux = {}
-- {{{ CPU frequency widget type
@ -58,4 +58,4 @@ local function worker(format, warg)
end
-- }}}
return setmetatable(cpufreq, { __call = function(_, ...) return worker(...) end })
return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end })