mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
CPU: use module options
This commit is contained in:
+27
-20
@@ -7,9 +7,16 @@
|
||||
|
||||
void ffPrintCPU(FFinstance* instance, FFCPUOptions* options)
|
||||
{
|
||||
const FFCPUResult* cpu = ffDetectCPU(instance);
|
||||
FFCPUResult cpu;
|
||||
cpu.temperature = FF_CPU_TEMP_UNSET;
|
||||
cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0;
|
||||
cpu.frequencyMax = cpu.frequencyMin = 0;
|
||||
ffStrbufInit(&cpu.name);
|
||||
ffStrbufInit(&cpu.vendor);
|
||||
|
||||
if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1)
|
||||
ffDetectCPU(instance, options, &cpu);
|
||||
|
||||
if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1)
|
||||
{
|
||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected");
|
||||
return;
|
||||
@@ -19,38 +26,38 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key);
|
||||
|
||||
if(cpu->name.length > 0)
|
||||
ffStrbufWriteTo(&cpu->name, stdout);
|
||||
else if(cpu->vendor.length > 0)
|
||||
if(cpu.name.length > 0)
|
||||
ffStrbufWriteTo(&cpu.name, stdout);
|
||||
else if(cpu.vendor.length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&cpu->vendor, stdout);
|
||||
ffStrbufWriteTo(&cpu.vendor, stdout);
|
||||
fputs(" CPU", stdout);
|
||||
}
|
||||
else
|
||||
fputs("CPU", stdout);
|
||||
|
||||
if(cpu->coresOnline > 1)
|
||||
printf(" (%u)", cpu->coresOnline);
|
||||
if(cpu.coresOnline > 1)
|
||||
printf(" (%u)", cpu.coresOnline);
|
||||
|
||||
if(cpu->frequencyMax > 0.0)
|
||||
printf(" @ %.9g GHz", cpu->frequencyMax);
|
||||
if(cpu.frequencyMax > 0.0)
|
||||
printf(" @ %.9g GHz", cpu.frequencyMax);
|
||||
|
||||
if(cpu->temperature == cpu->temperature) //FF_CPU_TEMP_UNSET
|
||||
printf(" - %.1f°C", cpu->temperature);
|
||||
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
|
||||
printf(" - %.1f°C", cpu.temperature);
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.temperature}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user