summaryrefslogtreecommitdiffstats
path: root/main/xfce4-battery-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'main/xfce4-battery-plugin')
-rw-r--r--main/xfce4-battery-plugin/sysfs-temp.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/main/xfce4-battery-plugin/sysfs-temp.patch b/main/xfce4-battery-plugin/sysfs-temp.patch
new file mode 100644
index 000000000..d20680ed8
--- /dev/null
+++ b/main/xfce4-battery-plugin/sysfs-temp.patch
@@ -0,0 +1,66 @@
+From e33899de3205edfc0b2c330f43da6a4bc8141b85 Mon Sep 17 00:00:00 2001
+From: Florian Rivoal <frivoal@xfce.org>
+Date: Sat, 26 Feb 2011 13:53:09 +0000
+Subject: Add support for getting the temperature from sysfs
+
+Up to the linux kernel version 2.6.37, this information was available in
+the proc file system, but after that, it is only available from the sys
+file system.
+
+This fixes bug #7339.
+---
+diff --git a/panel-plugin/libacpi.c b/panel-plugin/libacpi.c
+index 838a760..0e368f4 100644
+--- a/panel-plugin/libacpi.c
++++ b/panel-plugin/libacpi.c
+@@ -1002,18 +1002,36 @@ const char *get_temperature(void)
+ #ifdef __linux__
+ FILE *fp;
+ char *proc_temperature="/proc/acpi/thermal_zone/*/temperature";
+- static char *p,line[256];
+-
+- if ( (fp=fopen_glob(proc_temperature, "r")) == NULL) return NULL;
+- fgets(line,255,fp);
+- fclose(fp);
+- p=strtok(line," ");
+- if (!p) return NULL;
+- p=p+strlen(p)+1;
+- while (p && *p ==' ') p++;
+- if (*p==0) return NULL;
+- if (strchr(p,'\n')) p=strtok(p,"\n");
+- return (const char *)p;
++ char *sys_temperature="/sys/class/thermal/thermal_zone*/temp";
++ static char *p,*p2,line[256];
++
++ if ( (fp=fopen_glob(proc_temperature, "r")) != NULL )
++ {
++ fgets(line,255,fp);
++ fclose(fp);
++ p=strtok(line," ");
++ if (!p) return NULL;
++ p=p+strlen(p)+1;
++ while (p && *p ==' ') p++;
++ if (*p==0) return NULL;
++ if (strchr(p,'\n')) p=strtok(p,"\n");
++ return (const char *)p;
++ }
++ else if ( (fp=fopen_glob(sys_temperature, "r")) != NULL )
++ {
++ fgets(line,255,fp);
++ fclose(fp);
++ p = line;
++ if (strchr(p,'\n')) *strchr(p,'\n') = 0;
++ if (strlen(p) <= 3) return NULL;
++ p2 = p + strlen(p) - 3;
++ strcpy(p2, " C");
++ return (const char *)p;
++ }
++ else
++ {
++ return NULL;
++ }
+ #else
+ #ifdef HAVE_SYSCTL
+ static char buf[BUFSIZ];
+--
+cgit v0.8.3.4