1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

Let $acpitemp use /sys instead of /proc

From the 2.6.36 changelog (http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.36):
Mark the ACPI thermal procfs I/F deprecated, because /sys/class/thermal/ is already available and has been working for years w/o any problem.
The ACPI thermal procfs I/F will be removed in 2.6.37
This commit is contained in:
Nikolas Garofil 2010-11-10 18:22:22 +01:00
parent b902b70e96
commit 1b90218c33

View File

@ -1449,26 +1449,20 @@ critical (S5): 73 C
passive: 73 C: tc1=4 tc2=3 tsp=40 devices=0xcdf6e6c0
*/
#define ACPI_THERMAL_DIR "/proc/acpi/thermal_zone/"
#define ACPI_THERMAL_FORMAT "/proc/acpi/thermal_zone/%s/temperature"
#define ACPI_THERMAL_ZONE_DEFAULT "thermal_zone0"
#define ACPI_THERMAL_FORMAT "/sys/class/thermal/%s/temp"
int open_acpi_temperature(const char *name)
{
char path[256];
char buf[256];
int fd;
if (name == NULL || strcmp(name, "*") == 0) {
static int rep = 0;
if (!get_first_file_in_a_directory(ACPI_THERMAL_DIR, buf, &rep)) {
return -1;
}
name = buf;
snprintf(path, 255, ACPI_THERMAL_FORMAT, ACPI_THERMAL_ZONE_DEFAULT);
} else {
snprintf(path, 255, ACPI_THERMAL_FORMAT, name);
}
snprintf(path, 255, ACPI_THERMAL_FORMAT, name);
fd = open(path, O_RDONLY);
if (fd < 0) {
NORM_ERR("can't open '%s': %s", path, strerror(errno));
@ -1480,6 +1474,9 @@ int open_acpi_temperature(const char *name)
static double last_acpi_temp;
static double last_acpi_temp_time;
//the maximum length of the string inside a ACPI_THERMAL_FORMAT file including the ending 0
#define MAXTHERMZONELEN 6
double get_acpi_temperature(int fd)
{
if (fd <= 0) {
@ -1497,15 +1494,16 @@ double get_acpi_temperature(int fd)
/* read */
{
char buf[256];
char buf[MAXTHERMZONELEN];
int n;
n = read(fd, buf, 255);
n = read(fd, buf, MAXTHERMZONELEN-1);
if (n < 0) {
NORM_ERR("can't read fd %d: %s", fd, strerror(errno));
} else {
buf[n] = '\0';
sscanf(buf, "temperature: %lf", &last_acpi_temp);
sscanf(buf, "%lf", &last_acpi_temp);
last_acpi_temp /= 1000;
}
}