mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
Temp (FreeBSD): improve CPU temp detection
This commit is contained in:
@@ -16,7 +16,10 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
cpu->temperature = FF_CPU_TEMP_UNSET;
|
||||
|
||||
if (options->temp)
|
||||
ffDetectThermalTemp(&cpu->temperature);
|
||||
{
|
||||
if (!ffDetectCpuTemp(&cpu->temperature))
|
||||
ffDetectThermalTemp(&cpu->temperature);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
#include "temps_bsd.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
const char* ffDetectCpuTemp(double* current)
|
||||
{
|
||||
int temp = ffSysctlGetInt("dev.cpu.0.temperature", -999999);
|
||||
if (temp == -999999)
|
||||
return "ffSysctlGetInt(\"dev.cpu.0.temperature\") failed";
|
||||
|
||||
// In tenth of degrees Celsius
|
||||
*current = (double) temp / 10;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectThermalTemp(double* current)
|
||||
{
|
||||
int temp = ffSysctlGetInt("hw.acpi.thermal.tz0.temperature", -999999);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef FF_INCLUDED_detection_temps_windows
|
||||
#define FF_INCLUDED_detection_temps_windows
|
||||
|
||||
const char* ffDetectCpuTemp(double* current);
|
||||
const char* ffDetectThermalTemp(double* current);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user