Fastfetch: add new option --temperature-unit

This commit is contained in:
李通洲
2023-07-27 15:58:49 +08:00
parent c9741d1662
commit af2c6a832e
11 changed files with 81 additions and 10 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
#include "common/printing.h"
#include "common/jsonconfig.h"
#include "common/bar.h"
#include "common/parsing.h"
#include "detection/battery/battery.h"
#include "modules/battery/battery.h"
#include "util/stringUtils.h"
@@ -54,7 +55,7 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
if(str.length > 0)
ffStrbufAppendS(&str, " - ");
ffStrbufAppendF(&str, "%.1f°C", result->temperature);
ffParseTemperature(result->temperature, &str);
}
ffStrbufPutTo(&str, stdout);
+14 -8
View File
@@ -1,5 +1,6 @@
#include "common/printing.h"
#include "common/jsonconfig.h"
#include "common/parsing.h"
#include "detection/cpu/cpu.h"
#include "modules/cpu/cpu.h"
#include "util/stringUtils.h"
@@ -31,26 +32,31 @@ void ffPrintCPU(FFCPUOptions* options)
{
ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
if(cpu.name.length > 0)
ffStrbufWriteTo(&cpu.name, stdout);
ffStrbufAppend(&str, &cpu.name);
else if(cpu.vendor.length > 0)
{
ffStrbufWriteTo(&cpu.vendor, stdout);
fputs(" CPU", stdout);
ffStrbufAppend(&str, &cpu.vendor);
ffStrbufAppendS(&str, " CPU");
}
else
fputs("CPU", stdout);
ffStrbufAppendS(&str, "Unknown");
if(cpu.coresOnline > 1)
printf(" (%u)", cpu.coresOnline);
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
if(cpu.frequencyMax > 0.0)
printf(" @ %.9g GHz", cpu.frequencyMax);
ffStrbufAppendF(&str, " @ %.9g GHz", cpu.frequencyMax);
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
printf(" - %.1f°C", cpu.temperature);
{
ffStrbufAppendS(&str, " - ");
ffParseTemperature(cpu.temperature, &str);
}
putchar('\n');
ffStrbufPutTo(&str, stdout);
}
else
{
+5 -1
View File
@@ -2,6 +2,7 @@
#include "common/parsing.h"
#include "common/printing.h"
#include "common/jsonconfig.h"
#include "common/parsing.h"
#include "detection/host/host.h"
#include "detection/gpu/gpu.h"
#include "modules/gpu/gpu.h"
@@ -39,7 +40,10 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature);
{
ffStrbufAppendS(&output, " - ");
ffParseTemperature(gpu->temperature, &output);
}
if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0)
{