! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
shows AC eeven when on battery
Status:
RESOLVED: FIXED
Product:
Xfce4-battery-plugin
Component:
General

Comments

Description Jani Monoses 2005-12-04 08:56:57 CET
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/pkg-xfce-devel@lists.alioth.debian.org/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.
Comment 1 Nick Schermer editbugs 2006-09-01 11:38:22 CEST
Applied some lines of it in the new 0.4.90.2 release. Thanks for patch.

Bug #1261

Reported by:
Jani Monoses
Reported on: 2005-12-04
Last modified on: 2010-12-24

People

Assignee:
Xfce-Goodies Maintainers
CC List:
1 user

Version

Version:
0.5.1 or older
Target Milestone:
0.5.1 or older

Attachments

Additional information