mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Merge pull request #177 from x-zvf/feature-cpu-temp
Add CPU package temperature to CPU module.
This commit is contained in:
@@ -12,7 +12,6 @@ Here i just add things that are easy to forget.
|
||||
- `libffprint`: contains the printing functions, logos, format etc
|
||||
- `fastfetch` and `flashfetch`: Executables, that initialize the config of libffprint. Fist one at runtime, second one at compile time
|
||||
- [ ] Better OS output for all possible combinations of /etc/os-release variables.
|
||||
- [ ] Expose temperatures to CPU format string
|
||||
- [ ] Expose temperatures to GPU format string
|
||||
- [ ] Find wayland compositor by looking at \${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}
|
||||
- [ ] Make LocalIP module more configurable
|
||||
|
||||
+2
-1
@@ -236,7 +236,7 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(strcasecmp(command, "cpu-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("cpu", "{2} ({7}) @ {14}GHz", 14,
|
||||
constructAndPrintCommandHelpFormat("cpu", "{2} ({7}) @ {15}GHz", 15,
|
||||
"CPU name",
|
||||
"Prettified CPU name",
|
||||
"CPU Vendor name (Vendor ID)",
|
||||
@@ -244,6 +244,7 @@ static inline void printCommandHelp(const char* command)
|
||||
"CPU logical core count configured",
|
||||
"CPU physical core count",
|
||||
"Always set core count",
|
||||
"CPU package temperature",
|
||||
"frequency bios limit",
|
||||
"frequency scaling max",
|
||||
"frequency scaling min",
|
||||
|
||||
+26
-4
@@ -1,15 +1,23 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define FF_CPU_MODULE_NAME "CPU"
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 14
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 15
|
||||
|
||||
static double parseHz(FFstrbuf* content)
|
||||
|
||||
static long parseLong(const FFstrbuf* content)
|
||||
{
|
||||
if(content->length == 0)
|
||||
return 0;
|
||||
long value;
|
||||
if(sscanf(content->chars, "%li", &value) != 1)
|
||||
return -1;
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
static double parseHz(const FFstrbuf* content)
|
||||
{
|
||||
double herz;
|
||||
if(sscanf(content->chars, "%lf", &herz) != 1)
|
||||
return 0;
|
||||
@@ -104,6 +112,19 @@ 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;
|
||||
@@ -172,6 +193,7 @@ void ffPrintCPU(FFinstance* instance)
|
||||
{FF_FORMAT_ARG_TYPE_INT, &numProcsAvailable},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &physicalCores},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &numProcs},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpuTemp},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &biosLimit},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMaxFreq},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMinFreq},
|
||||
|
||||
Reference in New Issue
Block a user