summaryrefslogtreecommitdiff
path: root/app-admin/conky/files/conky-1.8.1-acpitemp.patch
diff options
context:
space:
mode:
Diffstat (limited to 'app-admin/conky/files/conky-1.8.1-acpitemp.patch')
-rw-r--r--app-admin/conky/files/conky-1.8.1-acpitemp.patch81
1 files changed, 81 insertions, 0 deletions
diff --git a/app-admin/conky/files/conky-1.8.1-acpitemp.patch b/app-admin/conky/files/conky-1.8.1-acpitemp.patch
new file mode 100644
index 00000000..9632b99e
--- /dev/null
+++ b/app-admin/conky/files/conky-1.8.1-acpitemp.patch
@@ -0,0 +1,81 @@
+From 1b90218c339467770254aba03e3f0a3acc4af4b0 Mon Sep 17 00:00:00 2001
+From: Nikolas Garofil <nikolas@garofil.be>
+Date: Wed, 10 Nov 2010 18:22:22 +0100
+Subject: [PATCH] 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
+---
+ src/linux.cc | 26 ++++++++++++--------------
+ 1 files changed, 12 insertions(+), 14 deletions(-)
+
+diff --git a/src/linux.cc b/src/linux.cc
+index ae97f48..bfb0063 100644
+--- a/src/linux.c
++++ b/src/linux.c
+@@ -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;
+ }
+ }
+
+--
+1.7.0.4
+