add cpufreq and cpuinf widget (not tested for date like bug)

This commit is contained in:
mutlusun 2017-01-05 10:48:25 +01:00
parent 8e9c7b62ac
commit d52a1dc3a6
7 changed files with 64 additions and 35 deletions

View File

@ -171,6 +171,32 @@ Supported platforms: Linux, FreeBSD.
* returns 1st value as usage of all CPUs/cores, 2nd as usage of first * returns 1st value as usage of all CPUs/cores, 2nd as usage of first
CPU/core, 3rd as usage of second CPU/core etc. CPU/core, 3rd as usage of second CPU/core etc.
**vicious.widgets.cpufreq**
Provides freq, voltage and governor info for a requested CPU.
Supported platforms: Linux, FreeBSD.
- Arguments (per platform):
* Linux: takes the CPU ID as an argument, i.e. "cpu0"
* FreeBSD: takes the CPU ID as an argument, i.e. "0"
- Returns (per platform):
* Linux: returns 1st value as frequency of requested CPU in MHz, 2nd in GHz,
3rd as voltage in mV, 4th as voltage in V and 5th as the governor state
* FreeBSD: returns 1st value as frequency of requested CPU in MHz, 2nd in GHz,
3rd as voltage in mV, 4th as voltage in V and 5th as the governor state,
but only the first two are supported (other values will be always `"N/A"`)
**vicious.widgets.cpuinf**
Provides speed and cache information for all available CPUs/cores.
Supported platforms: Linux.
- Arguments:
* None
- Returns:
* returns a table with string keys, using CPU ID as a base: `{cpu0 mhz}`,
`{cpu0 ghz}`, `{cpu0 kb}`, `{cpu0 mb}`, `{cpu1 mhz}` etc.
**vicious.widgets.date** **vicious.widgets.date**
Provides access to os.date, with optional time formatting provided as the Provides access to os.date, with optional time formatting provided as the
@ -336,20 +362,6 @@ Supported platforms: platform independent.
`{windkmh}`, `{sky}`, `{weather}`, `{tempf}`, `{tempc}`, `{humid}`, `{windkmh}`, `{sky}`, `{weather}`, `{tempf}`, `{tempc}`, `{humid}`,
`{dewf}`, `{dewc}` and `{press}` `{dewf}`, `{dewc}` and `{press}`
**vicious.widgets.cpuinf**
- provides speed and cache information for all available CPUs/cores
- returns a table with string keys, using CPU ID as a base:
{cpu0 mhz}, {cpu0 ghz}, {cpu0 kb}, {cpu0 mb}, {cpu1 mhz} etc.
**vicious.widgets.cpufreq**
- provides freq, voltage and governor info for a requested CPU
- takes the CPU ID as an argument, i.e. "cpu0"
- returns 1st value as frequency of requested CPU in MHz, 2nd in
GHz, 3rd as voltage in mV, 4th as voltage in V and 5th as the
governor state
**vicious.widgets.mem** **vicious.widgets.mem**
- provides RAM and Swap usage statistics - provides RAM and Swap usage statistics

View File

@ -1,10 +1,3 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2011, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
-- * (c) 2011, Jörg Thalheim <jthalheim@gmail.com>
---------------------------------------------------
-- {{{ Grab environment -- {{{ Grab environment
local helpers = require("vicious.helpers") local helpers = require("vicious.helpers")
local tonumber = tonumber local tonumber = tonumber

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

View File

@ -13,7 +13,7 @@ local string = { gmatch = string.gmatch }
-- Cpuinf: provides speed and cache information for all available CPUs/cores -- Cpuinf: provides speed and cache information for all available CPUs/cores
-- vicious.widgets.cpuinf -- vicious.widgets.cpuinf
local cpuinf = {} local cpuinf_linux = {}
-- {{{ CPU Information widget type -- {{{ CPU Information widget type
@ -41,4 +41,4 @@ local function worker(format)
end end
-- }}} -- }}}
return setmetatable(cpuinf, { __call = function(_, ...) return worker(...) end }) return setmetatable(cpuinf_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,8 +1,3 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- {{{ Grab environment -- {{{ Grab environment
local setmetatable = setmetatable local setmetatable = setmetatable
local string = { match = string.match } local string = { match = string.match }

View File

@ -1,8 +1,3 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- {{{ Grab environment -- {{{ Grab environment
local tonumber = tonumber local tonumber = tonumber
local io = { popen = io.popen } local io = { popen = io.popen }