1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-13 11:15:27 +00:00

Try more than one sysctl to get CPU temperature. (#330)

* Try more than one sysctl to get CPU temperature.

Suggested by:	walter@pelissero.de
Reference:	https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210235

* Added braces and using else ifs.
This commit is contained in:
Guido Falsi 2016-10-07 19:54:35 +02:00 committed by Brenden Matthews
parent e51301a0f8
commit 271ca6dc97

View File

@ -426,13 +426,16 @@ double get_acpi_temperature(int fd)
int temp;
(void)fd;
if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
fprintf(stderr,
"Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
return 0.0;
if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp) == 0) {
return KELVTOC(temp);
} else if (GETSYSCTL("dev.cpu.0.temperature", temp) == 0) {
return KELVTOC(temp);
} else if (GETSYSCTL("dev.amdtemp.0.core0.sensor0", temp) == 0) {
return KELVTOC(temp);
}
fprintf(stderr, "Cannot get temperature from sysctl\n");
return KELVTOC(temp);
return 0.0;
}
static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {