|
1 | 1 | #include "fastfetch.h" |
2 | 2 |
|
3 | 3 | #include <string.h> |
| 4 | +#include <errno.h> |
4 | 5 |
|
5 | 6 | #define FF_CPU_MODULE_NAME "CPU" |
6 | | -#define FF_CPU_NUM_FORMAT_ARGS 14 |
| 7 | +#define FF_CPU_NUM_FORMAT_ARGS 15 |
7 | 8 |
|
8 | | -static double parseHz(FFstrbuf* content) |
| 9 | + |
| 10 | +static long parseLong(const FFstrbuf* content) |
9 | 11 | { |
10 | | - if(content->length == 0) |
11 | | - return 0; |
| 12 | + long value; |
| 13 | + if(sscanf(content->chars, "%li", &value) != 1) |
| 14 | + return -1; |
| 15 | + return value; |
12 | 16 |
|
| 17 | +} |
| 18 | + |
| 19 | +static double parseHz(const FFstrbuf* content) |
| 20 | +{ |
13 | 21 | double herz; |
14 | 22 | if(sscanf(content->chars, "%lf", &herz) != 1) |
15 | 23 | return 0; |
@@ -104,6 +112,19 @@ void ffPrintCPU(FFinstance* instance) |
104 | 112 | if(numProcs <= 1) |
105 | 113 | numProcs = physicalCores; |
106 | 114 |
|
| 115 | + |
| 116 | + const FFTempsResult *temps = ffDetectTemps(&instance); |
| 117 | + double cpuTemp = 0.0/0.0; |
| 118 | + for(uint32_t i = 0; i< temps->values.length; i++) |
| 119 | + { |
| 120 | + FFTempValue *v = ffListGet(&temps->values, i); |
| 121 | + if(ffStrbufFirstIndexS(&v->name, "cpu") == v->name.length |
| 122 | + && ffStrbufCompS(&v->name, "k10temp") != 0 |
| 123 | + && ffStrbufCompS(&v->name, "coretemp") != 0) |
| 124 | + break; |
| 125 | + cpuTemp = (double) parseLong(&v->value) / 1000.0f; |
| 126 | + } |
| 127 | + |
107 | 128 | double ghz = biosLimit; |
108 | 129 | if(ghz == 0) |
109 | 130 | ghz = scalingMaxFreq; |
@@ -172,6 +193,7 @@ void ffPrintCPU(FFinstance* instance) |
172 | 193 | {FF_FORMAT_ARG_TYPE_INT, &numProcsAvailable}, |
173 | 194 | {FF_FORMAT_ARG_TYPE_INT, &physicalCores}, |
174 | 195 | {FF_FORMAT_ARG_TYPE_INT, &numProcs}, |
| 196 | + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpuTemp}, |
175 | 197 | {FF_FORMAT_ARG_TYPE_DOUBLE, &biosLimit}, |
176 | 198 | {FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMaxFreq}, |
177 | 199 | {FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMinFreq}, |
|
0 commit comments