diff options
author | Arvydas Sidorenko <asido4@gmail.com> | 2012-06-15 18:07:05 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2012-06-18 01:26:31 +0200 |
commit | 41cc2c0e27e6a0860d21754ed9d13f6cd61254ac (patch) | |
tree | 20ed8fe7b878caec0c9e033168fe79561f31db57 /widgets/cpufreq.lua | |
parent | b6b52900930ddb2a5b958a6d314766b455358164 (diff) | |
download | vicious-legacy-41cc2c0e27e6a0860d21754ed9d13f6cd61254ac.tar.xz |
Ported vicious.widgets module to lua 5.2
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
Diffstat (limited to 'widgets/cpufreq.lua')
-rw-r--r-- | widgets/cpufreq.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/widgets/cpufreq.lua b/widgets/cpufreq.lua index ba9749f..39470a4 100644 --- a/widgets/cpufreq.lua +++ b/widgets/cpufreq.lua @@ -12,14 +12,15 @@ local helpers = require("vicious.helpers") -- Cpufreq: provides freq, voltage and governor info for a requested CPU -module("vicious.widgets.cpufreq") +-- vicious.widgets.cpufreq +local cpufreq = {} -- {{{ CPU frequency widget type local function worker(format, warg) if not warg then return end - local cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq") + local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq") local governor_state = { ["ondemand\n"] = "↯", ["powersave\n"] = "⌁", @@ -34,22 +35,22 @@ local function worker(format, warg) } -- Get the current frequency - local freq = tonumber(cpufreq.scaling_cur_freq) + local freq = tonumber(_cpufreq.scaling_cur_freq) -- Calculate MHz and GHz if freq then freqv.mhz = freq / 1000 freqv.ghz = freqv.mhz / 1000 -- Get the current voltage - if cpufreq.scaling_voltages then - freqv.mv = tonumber(string.match(cpufreq.scaling_voltages, freq.."[%s]([%d]+)")) + if _cpufreq.scaling_voltages then + freqv.mv = tonumber(string.match(_cpufreq.scaling_voltages, freq.."[%s]([%d]+)")) -- Calculate voltage from mV freqv.v = freqv.mv / 1000 end end -- Get the current governor - local governor = cpufreq.scaling_governor + local governor = _cpufreq.scaling_governor -- Represent the governor as a symbol governor = governor_state[governor] or governor or "N/A" @@ -57,4 +58,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpufreq, { __call = function(_, ...) return worker(...) end }) |