Skip to content

Commit 481affa

Browse files
Fix cpu temp detection
1 parent a33e296 commit 481affa

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

presets/verbose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
--cursor-format "Theme: {}; Size: {}"
1818
--terminal-format "Process: {}; Path: {}; Exe: {}"
1919
--terminal-font-format "Raw: {}; Name: {}; Size: {}; Styles: {}; Pretty: {}"
20-
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; bios: {}; temperature: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
20+
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; temperature: {}; bios: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
2121
--cpu-usage-format "Percentage: {}"
2222
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}"
2323
--memory-format "Used: {}; Total: {}; Percentage: {}"

src/common/format.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static inline bool formatArgSet(const FFformatarg* arg)
7272
{
7373
return arg->value != NULL && (
7474
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value > 0) ||
75+
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value == *(double*)arg->value) || //NaN
7576
(arg->type == FF_FORMAT_ARG_TYPE_INT && *(int*)arg->value > 0) ||
7677
(arg->type == FF_FORMAT_ARG_TYPE_STRBUF && ((FFstrbuf*)arg->value)->length > 0) ||
7778
(arg->type == FF_FORMAT_ARG_TYPE_STRING && *(const char*)arg->value != '\0') ||

src/modules/cpu.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,21 @@ void ffPrintCPU(FFinstance* instance)
150150
ffStrbufSubstrBeforeFirstC(&namePretty, '@'); //Cut the speed output in the name as we append our own
151151
ffStrbufTrimRight(&namePretty, ' '); //If we removed the @ in previous step there was most likely a space before it
152152

153-
const FFTempsResult *temps = ffDetectTemps(&instance);
153+
const FFTempsResult *temps = ffDetectTemps(instance);
154154
double cpuTemp = 0.0/0.0; //NaN
155155

156-
for(uint32_t i = 0; i< temps->values.length; i++)
156+
for(uint32_t i = 0; i < temps->values.length; i++)
157157
{
158-
FFTempValue *v = ffListGet(&temps->values, i);
159-
if(
160-
ffStrbufFirstIndexS(&v->name, "cpu") == v->name.length &&
161-
ffStrbufCompS(&v->name, "k10temp") != 0 &&
162-
ffStrbufCompS(&v->name, "coretemp") != 0
163-
) break;
158+
FFTempValue* value = ffListGet(&temps->values, i);
164159

165-
cpuTemp = (double) parseLong(&v->value) / 1000.0;
160+
if(
161+
ffStrbufFirstIndexS(&value->name, "cpu") < value->name.length ||
162+
ffStrbufCompS(&value->name, "k10temp") == 0 ||
163+
ffStrbufCompS(&value->name, "coretemp") == 0
164+
) {
165+
cpuTemp = (double) parseLong(&value->value) / 1000.0;
166+
break;
167+
}
166168
}
167169

168170
FFstrbuf cpu;

0 commit comments

Comments
 (0)