After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 309398 - AC adapter state not updated if no event accompanies the change.
AC adapter state not updated if no event accompanies the change.
Status: RESOLVED DUPLICATE of bug 163013
Product: gnome-applets
Classification: Other
Component: battery
2.10.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-applets Maintainers
gnome-applets Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-07-03 18:58 UTC by Jarrod Johnson
Modified: 2005-07-03 19:37 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10



Description Jarrod Johnson 2005-07-03 18:58:26 UTC
Distribution/Version: Ubuntu 5.04

The AC adapter state can change without ACPI event in the following method (at
least on my laptop):
-Initial state: plugged in
-Put laptop to sleep (or suspend to disk)
-Unplug AC adapter
-Resume laptop.
(or vice-versa, plugging laptop in during sleep if it was originally not does
same thing)
The battstat applet will continue for eternity to have the icon suggest that AC
power is connected.

Here is a quick patch I used for my purposes:
--- gnome-applets-2.10.1/battstat/acpi-linux.c  2005-01-13 23:06:40.000000000 -0500
+++ gnome-applets-2.10.1-patch/battstat/acpi-linux.c    2005-07-01
22:55:32.000000000 -0400
@@ -374,6 +375,8 @@
   /* Get the remaining capacity for the batteries.  Other information
    * such as AC state and battery max capacity are read only when they
    * change using acpi_process_event(). */
+  /* State changes during sleep do not have associated events */
+  update_ac_info(acpiinfo);
   while ((procdirentry=readdir(procdir)))
    {
     if (procdirentry->d_name[0]!='.')

There might be another approach more elegant, i.e. being notified explicitly of
resume, however, no ACPI event accompanies it that I can tell and other
solutions would require sleep/resume scripts to pass data to battstat, which
varies between distros.  This approach checks status of ac adapter every battery
update, which means it doesn't update immediately on resume, but at least it is
better than the current behavior.
Comment 1 Allison Karlitskaya (desrt) 2005-07-03 19:37:10 UTC
Hi.  Thanks for the report and the patch.

A patch similar to yours is already in bug 163013.

This is a long-standing known issue and we're looking at a better way of fixing
it.  Doing an update of the AC info for every battery refresh is a little bit
excessive.  If we were to go this route, a lot of the current ACPI code would
just be completely ripped out (since this removes the point of separate event
notifications).

*** This bug has been marked as a duplicate of 163013 ***