mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Finish exposing temperatur to cpu format
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
||||
--cursor-format "Theme: {}; Size: {}"
|
||||
--terminal-format "Process: {}; Path: {}; Exe: {}"
|
||||
--terminal-font-format "Raw: {}; Name: {}; Size: {}; Styles: {}; Pretty: {}"
|
||||
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; bios: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
|
||||
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; bios: {}; temperatur: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
|
||||
--cpu-usage-format "Percentage: {}"
|
||||
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}"
|
||||
--memory-format "Used: {}; Total: {}; Percentage: {}"
|
||||
|
||||
+19
-18
@@ -6,17 +6,16 @@
|
||||
#define FF_CPU_MODULE_NAME "CPU"
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 15
|
||||
|
||||
|
||||
static long parseLong(const FFstrbuf* content)
|
||||
{
|
||||
long value;
|
||||
if(sscanf(content->chars, "%li", &value) != 1)
|
||||
return -1;
|
||||
return value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static double parseHz(const FFstrbuf* content)
|
||||
static double parseDouble(const FFstrbuf* content)
|
||||
{
|
||||
double herz;
|
||||
if(sscanf(content->chars, "%lf", &herz) != 1)
|
||||
@@ -34,7 +33,7 @@ static double getGhz(const char* policyFile, const char* cpuFile)
|
||||
if(content.length == 0)
|
||||
ffGetFileContent(cpuFile, &content);
|
||||
|
||||
double herz = parseHz(&content);
|
||||
double herz = parseDouble(&content);
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
|
||||
@@ -89,7 +88,7 @@ void ffPrintCPU(FFinstance* instance)
|
||||
|
||||
fclose(cpuinfo);
|
||||
|
||||
double procGhz = parseHz(&procGhzString) / 1000.0; //to GHz
|
||||
double procGhz = parseDouble(&procGhzString) / 1000.0; //to GHz
|
||||
ffStrbufDestroy(&procGhzString);
|
||||
|
||||
double biosLimit = getGhz("/sys/devices/system/cpu/cpufreq/policy0/bios_limit", "/sys/devices/system/cpu/cpu0/cpufreq/bios_limit");
|
||||
@@ -112,19 +111,6 @@ void ffPrintCPU(FFinstance* instance)
|
||||
if(numProcs <= 1)
|
||||
numProcs = physicalCores;
|
||||
|
||||
|
||||
const FFTempsResult *temps = ffDetectTemps(&instance);
|
||||
double cpuTemp = 0.0/0.0;
|
||||
for(uint32_t i = 0; i< temps->values.length; i++)
|
||||
{
|
||||
FFTempValue *v = ffListGet(&temps->values, i);
|
||||
if(ffStrbufFirstIndexS(&v->name, "cpu") == v->name.length
|
||||
&& ffStrbufCompS(&v->name, "k10temp") != 0
|
||||
&& ffStrbufCompS(&v->name, "coretemp") != 0)
|
||||
break;
|
||||
cpuTemp = (double) parseLong(&v->value) / 1000.0f;
|
||||
}
|
||||
|
||||
double ghz = biosLimit;
|
||||
if(ghz == 0)
|
||||
ghz = scalingMaxFreq;
|
||||
@@ -164,6 +150,21 @@ void ffPrintCPU(FFinstance* instance)
|
||||
ffStrbufSubstrBeforeFirstC(&namePretty, '@'); //Cut the speed output in the name as we append our own
|
||||
ffStrbufTrimRight(&namePretty, ' '); //If we removed the @ in previous step there was most likely a space before it
|
||||
|
||||
const FFTempsResult *temps = ffDetectTemps(&instance);
|
||||
double cpuTemp = 0.0/0.0; //NaN
|
||||
|
||||
for(uint32_t i = 0; i< temps->values.length; i++)
|
||||
{
|
||||
FFTempValue *v = ffListGet(&temps->values, i);
|
||||
if(
|
||||
ffStrbufFirstIndexS(&v->name, "cpu") == v->name.length &&
|
||||
ffStrbufCompS(&v->name, "k10temp") != 0 &&
|
||||
ffStrbufCompS(&v->name, "coretemp") != 0
|
||||
) break;
|
||||
|
||||
cpuTemp = (double) parseLong(&v->value) / 1000.0;
|
||||
}
|
||||
|
||||
FFstrbuf cpu;
|
||||
ffStrbufInitA(&cpu, 128);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user