[Goodies-commits] r5951 - xfce4-sensors-plugin/trunk/lib

Fabian Nowak timystery at xfce.org
Tue Nov 4 01:31:43 CET 2008


Author: timystery
Date: 2008-11-04 00:31:42 +0000 (Tue, 04 Nov 2008)
New Revision: 5951

Modified:
   xfce4-sensors-plugin/trunk/lib/acpi.c
Log:
more changes to acpi and sysfs stuff


Modified: xfce4-sensors-plugin/trunk/lib/acpi.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/acpi.c	2008-11-04 00:16:38 UTC (rev 5950)
+++ xfce4-sensors-plugin/trunk/lib/acpi.c	2008-11-04 00:31:42 UTC (rev 5951)
@@ -183,16 +183,29 @@
     double value;
 
     FILE *file;
-    char buf [1024], *filename, *tmp;
+    char buf [1024], *filename;
+#ifndef HAVE_SYSFSACPI
+    char *tmp;
+#endif
 
     TRACE ("enters get_battery_zone_value for %s", zone);
 
     value = 0.0;
 
+#ifdef HAVE_SYSFSACPI
+    filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_full", name);
+#else
     filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_BATTERY,
                                 zone, ACPI_FILE_BATTERY_STATE);
+#endif
     file = fopen (filename, "r");
     if (file) {
+#ifdef HAVE_SYSFSACPI
+        if (fgets (buf, 1024, file)!=NULL)
+        {
+            value = strtod (buf, NULL);
+        }
+#else
         while (fgets (buf, 1024, file)!=NULL)
         {
             if (strncmp (buf, "remaining capacity:", 19)==0)
@@ -202,6 +215,7 @@
                 break;
             }
         }
+#endif
         /*  g_free (tmp); */ /* points to inside the buffer! */
         fclose (file);
     }




More information about the Goodies-commits mailing list