Created
May 16, 2012 16:51
-
-
Save Mic92/2712136 to your computer and use it in GitHub Desktop.
Patch to vicious.widgets.cpufreq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From bd419aaee1c3488a8ebfc51093975d978305af6d Mon Sep 17 00:00:00 2001 | |
From: jinleileiking <jinleileiking@gmail.com> | |
Date: Wed, 16 May 2012 18:37:15 +0200 | |
Subject: [PATCH] cpufreq: handle not existing frequency/governer | |
In some cases not all cpu informations will be provided. | |
(ex. in virtual machines) | |
Therefore default to "N/A". | |
--- | |
widgets/cpufreq.lua | 13 ++++++++++--- | |
1 Datei geändert, 10 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-) | |
diff --git a/widgets/cpufreq.lua b/widgets/cpufreq.lua | |
index a4f2eaa..11949da 100644 | |
--- a/widgets/cpufreq.lua | |
+++ b/widgets/cpufreq.lua | |
@@ -29,13 +29,20 @@ local function worker(format, warg) | |
} | |
-- Default voltage values | |
local voltage = { v = "N/A", mv = "N/A" } | |
+ local freqmhz = "N/A" | |
+ local freqghz = "N/A" | |
-- Get the current frequency | |
local freq = tonumber(cpufreq.scaling_cur_freq) | |
-- Calculate MHz and GHz | |
- local freqmhz = freq / 1000 | |
- local freqghz = freqmhz / 1000 | |
+ | |
+ if freq then | |
+ freqmhz = freq / 1000 | |
+ freqghz = freqmhz / 1000 | |
+ end | |
+ | |
+ | |
-- Get the current voltage | |
if cpufreq.scaling_voltages then | |
@@ -47,7 +54,7 @@ local function worker(format, warg) | |
-- Get the current governor | |
local governor = cpufreq.scaling_governor | |
-- Represent the governor as a symbol | |
- governor = governor_state[governor] or governor | |
+ governor = governor_state[governor] or governor or "N/A" | |
return {freqmhz, freqghz, voltage.mv, voltage.v, governor} | |
end | |
-- | |
1.7.10.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment