Temps: add options to enable detection ( disabled by default )

This commit is contained in:
李通洲
2022-09-26 11:06:21 +08:00
parent 5fdb0719f2
commit 100e59fd49
9 changed files with 34 additions and 5 deletions
+3
View File
@@ -177,6 +177,9 @@ __fastfetch_completion()
"--allow-slow-operations"
"--disable-linewrap"
"--hide-cursor"
"--cpu-temp"
"--gpu-temp"
"--battery-temp"
"--localip-show-ipv4"
"--localip-show-ipv6"
"--localip-show-loop"
+3
View File
@@ -94,6 +94,9 @@ Module specific options:
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
--disk-removable <?value>: Sets if removable volume should be printed. Default is false
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
--localip-show-ipv4 <?value>: Show ipv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show ipv6 addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
+4 -1
View File
@@ -94,7 +94,10 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
else
ffStrbufAppendS(&battery->status, "");
battery->temperature = detectBatteryTemp();
if(instance->config.batteryTemp)
battery->temperature = detectBatteryTemp();
else
battery->temperature = FF_BATTERY_TEMP_UNSET;
CFRelease(properties);
IOObjectRelease(registryEntry);
+4 -1
View File
@@ -69,5 +69,8 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
cpu->frequencyMax = getFrequency("hw.cpufrequency");
}
cpu->temperature = detectCpuTemp(&cpu->name);
if (instance->config.cpuTemp)
cpu->temperature = detectCpuTemp(&cpu->name);
else
cpu->temperature = FF_CPU_TEMP_UNSET;
}
+4 -1
View File
@@ -80,7 +80,10 @@ static double detectCPUTemp(const FFinstance* instance)
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
{
cpu->temperature = detectCPUTemp(instance);
if(instance->config.cpuTemp)
cpu->temperature = detectCPUTemp(instance);
else
cpu->temperature = FF_CPU_TEMP_UNSET;
if(cached)
return;
+4 -1
View File
@@ -84,7 +84,10 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount))
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = detectGpuTemp(&gpu->name);
if(instance->config.gpuTemp)
gpu->temperature = detectGpuTemp(&gpu->name);
else
gpu->temperature = FF_GPU_TEMP_UNSET;
CFRelease(properties);
IOObjectRelease(registryEntry);
+2 -1
View File
@@ -200,7 +200,8 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
pciDetectTemperatur(instance, gpu, device);
if(instance->config.gpuTemp)
pciDetectTemperatur(instance, gpu, device);
}
static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus)
+6
View File
@@ -1253,6 +1253,12 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
//Module options//
//////////////////
else if(strcasecmp(key, "--cpu-temp") == 0)
instance->config.cpuTemp = optionParseBoolean(value);
else if(strcasecmp(key, "--gpu-temp") == 0)
instance->config.gpuTemp = optionParseBoolean(value);
else if(strcasecmp(key, "--battery-temp") == 0)
instance->config.batteryTemp = optionParseBoolean(value);
else if(strcasecmp(key, "--title-fqdn") == 0)
instance->config.titleFQDN = optionParseBoolean(value);
else if(strcasecmp(key, "--disk-folders") == 0)
+4
View File
@@ -152,6 +152,10 @@ typedef struct FFconfig
FFstrbuf libplist;
FFstrbuf libcJSON;
bool cpuTemp;
bool gpuTemp;
bool batteryTemp;
bool titleFQDN;
FFstrbuf diskFolders;