[Bug 1261] New: shows AC eeven when on battery

[email protected]
Newsgroups gmane.comp.desktop.xfce.goodies.devel
Message-ID <[email protected]>
Do NOT reply to this email.  To make further comments on this bug, use
the URL below:
http://bugzilla.xfce.org/show_bug.cgi?id=1261

           Summary: shows AC eeven when on battery
           Product: Xfce Panel Plugins
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: Medium
         Component: battery
        AssignedTo: [email protected]
        ReportedBy: [email protected]


reading /proc/acpi/battery on newer linux versions does not work with current code
so even when unplugged the battery plugin reports it's on AC power.
see this link for the fix in ubuntu, and the actual patch below
http://utnubu.alioth.debian.org/scottish/by_maint/[email protected]/large/xfce4-battery-plugin/xfce4-battery-plugin_0.3.0-1ubuntu1_packaging.patch

--
/home/jani/hack/ubuntu/xfce/packages/orig/battery/orig/xfce4-battery-plugin-0.3.0/panel-plugin/libacpi.c
    2003-09-0+++ libacpi.c   2005-10-07 18:05:53.000000000 +0300
@@ -272,12 +272,29 @@
   FILE *acpi;
   char *ptr;
   char stat;
+  DIR *acdir;
+  struct dirent *ac;
+  char *name;
+  char acstatus[128];
+
+  acdir = opendir("/proc/acpi/ac_adapter");
+  if (!acdir)
+    return -1;
+/* Works with ACPI versions newer than feb 2002, but this is for 2.6 kernels
only anyway */
+  while(ac = readdir(acdir)) {
+
+    name = ac->d_name;
+
+    /* skip . and .. */
+    if (name[0] == '.')
+        continue;
+    sprintf (acstatus, "/proc/acpi/ac_adapter/%s/state", name);
+    if (!(acpi = fopen (acstatus, "r")))
+        return -1;
+    break;
+  }

  if (!(acpi = fopen ("/proc/acpi/ac_adapter/0/status", "r")))
    if (!(acpi = fopen ("/proc/acpi/ac_adapter/ACAD/state", "r")))
      if (!(acpi = fopen ("/proc/acpi/ac_adapter/AC/state", "r")))
                                                                               
                       


Reproducible: Always
Steps to Reproduce:
1. 
2. 
3.

-- 
Configure bugmail: http://bugzilla.xfce.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
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.