battery-plugin: temperature (patch inside)

Ralf Meyer <[email protected]>
Newsgroups gmane.comp.desktop.xfce.goodies.devel
Message-ID <[email protected]>
Hi,

I've seen different behavior of battpanel on two different laptops.
One showed the temperature, the other didn't.
The culprit is:
in libacpi.c there it only tries to open
  /proc/acpi/thermal_zone/THRM/temperature
while on the 2nd laptop it has to be
  /proc/acpi/thermal_zone/ATF0/temperature

By looking at the source I saw that it also checks for the fan.
I made a change there as well.

Here is a simple patch:
-- 
bye 
  ranf
patch (text/x-patch, 1.5 KB)
diff -Nurp xfce4-battery-plugin-0.2.0_orig/panel-plugin/libacpi.c xfce4-battery-plugin-0.2.0/panel-plugin/libacpi.c
--- xfce4-battery-plugin-0.2.0_orig/panel-plugin/libacpi.c	2003-09-09 15:49:16.000000000 +0200
+++ xfce4-battery-plugin-0.2.0/panel-plugin/libacpi.c	2005-06-09 09:17:02.951077280 +0200
@@ -665,14 +665,14 @@ int get_fan_status(void)
   /*int result;*/
 
    /* Check for fan status in PROC filesystem */
-    if ( (fp=fopen(proc_fan_status, "r")) != NULL ) {
- 	  fgets(line,255,fp);
-  	  fclose(fp);
-  	  if (strlen(line) && strstr(line,"1")) return 1;
-    	  else return 0;
+    if ( (fp=fopen(proc_fan_status, "r")) == NULL ) {
+        proc_fan_status="/proc/acpi/fan/FAN/state";
+        if ( (fp=fopen(proc_fan_status, "r")) == NULL ) {
+            proc_fan_status="/proc/acpi/fan/LRA0/state";
+            if ( (fp=fopen(proc_fan_status, "r")) == NULL ) 
+                return 0; 
+        }    
     }
-    proc_fan_status="/proc/acpi/fan/FAN/state";
-    if ( (fp=fopen(proc_fan_status, "r")) == NULL ) return 0; 
     
     fgets(line,255,fp);
     fclose(fp);
@@ -688,7 +688,11 @@ const char *get_temperature(void)
   char *proc_temperature="/proc/acpi/thermal_zone/THRM/temperature";
   static char *p,line[256];
 
-  if ( (fp=fopen(proc_temperature, "r")) == NULL) return NULL;
+  if ( (fp=fopen(proc_temperature, "r")) == NULL) {
+    proc_temperature="/proc/acpi/thermal_zone/ATF0/temperature";
+    if ( (fp=fopen(proc_temperature, "r")) == NULL)
+      return NULL;
+  }
   fgets(line,255,fp);
   fclose(fp);
   p=strtok(line," ");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.