Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
12 return (pscanf(file
, "%d", &temp
) == 1) ?
13 bprintf("%d°C", temp
/ 1000) : NULL
;
15 #elif defined(__OpenBSD__)
19 #include <sys/time.h> /* before <sys/sensors.h> for struct timeval */
20 #include <sys/sensors.h>
21 #include <sys/sysctl.h>
24 temp(const char *unused
)
32 mib
[2] = 0; /* cpu0 */
34 mib
[4] = 0; /* temp0 */
38 if (sysctl(mib
, 5, &temp
, &size
, NULL
, 0) < 0) {
39 warn("sysctl 'SENSOR_TEMP':");
43 /* kelvin to celsius */
44 return bprintf("%d°C", (temp
.value
- 273150000) / 1000000);