diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2012-05-19 17:07:25 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2012-05-19 17:11:31 +0200 |
commit | 97e54d60f84601928416fe36dbb0d718930cc444 (patch) | |
tree | 312259a7a486d76379eb2e9566312d3b2523b7e1 /widgets | |
parent | 30db4bea7bd04df7d03edc31972f5da1f37887ad (diff) | |
download | vicious-legacy-97e54d60f84601928416fe36dbb0d718930cc444.tar.xz |
cpufreq: rework new exception handlers
Now that we are so nice to provide default frequency values check if
frequency exists before calculating voltage, not to screw up *those*
default values.
Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/cpufreq.lua | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/widgets/cpufreq.lua b/widgets/cpufreq.lua index 11949da..4a58ec2 100644 --- a/widgets/cpufreq.lua +++ b/widgets/cpufreq.lua @@ -27,28 +27,25 @@ local function worker(format, warg) ["performance\n"] = "⚡", ["conservative\n"] = "⊚" } - -- Default voltage values - local voltage = { v = "N/A", mv = "N/A" } - local freqmhz = "N/A" - local freqghz = "N/A" - + -- Default frequency and voltage values + local freqv = { + ["mhz"] = "N/A", ["ghz"] = "N/A", + ["v"] = "N/A", ["mv"] = "N/A", + } -- Get the current frequency local freq = tonumber(cpufreq.scaling_cur_freq) -- Calculate MHz and GHz - if freq then - freqmhz = freq / 1000 - freqghz = freqmhz / 1000 + freqv.mhz = freq / 1000 + freqv.ghz = freqv.mhz / 1000 end - - -- Get the current voltage - if cpufreq.scaling_voltages then - voltage.mv = tonumber(string.match(cpufreq.scaling_voltages, freq.."[%s]([%d]+)")) + if cpufreq.scaling_voltages and freq then + freqv.mv = tonumber(string.match(cpufreq.scaling_voltages, freq.."[%s]([%d]+)")) -- Calculate voltage from mV - voltage.v = voltage.mv / 1000 + freqv.v = freqv.mv / 1000 end -- Get the current governor @@ -56,7 +53,7 @@ local function worker(format, warg) -- Represent the governor as a symbol governor = governor_state[governor] or governor or "N/A" - return {freqmhz, freqghz, voltage.mv, voltage.v, governor} + return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor} end -- }}} |