! 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 !
[patch] Doesn't update when battery is removed or inserted
Status:
RESOLVED: FIXED
Product:
Xfce4-battery-plugin
Component:
General

Comments

Description John Lindgren editbugs 2018-12-01 07:31:42 CET
Created attachment 8144 
Patch 1/7

The plugin doesn't update when a battery is removed or inserted due to a couple of problems in the code:
 - It refuses to read any ACPI information at all until a battery is present (Linux only)
 - Once a battery is inserted, it never re-enumerates batteries to see if it was removed

Additionally, there is a lot of legacy code in the plugin that ought to be removed:
 - APM was deprecated in favor of ACPI two decades ago (for comparison, XP was the last Windows version to support it)
 - The /proc/acpi tree is no longer available on modern (3.x or 4.x) Linux kernels, ACPI information is under /sys now

I will attach a series of patches that:
 - Removes the legacy code (APM support for Linux + FreeBSD, and /proc/acpi support for Linux)
 - Fixes the Linux ACPI code to initialize properly when no battery is present
 - Re-detects whether a battery is present at the existing 30-second update interval

The full patch series can also be seen in my GitHub fork:
https://github.com/jlindgren90/xfce4-battery-plugin/commits/master
Comment 1 John Lindgren editbugs 2018-12-01 07:32:19 CET
Created attachment 8145 
Patch 2/7
Comment 2 John Lindgren editbugs 2018-12-01 07:33:27 CET
Created attachment 8146 
Patch 3/6
Comment 3 John Lindgren editbugs 2018-12-01 07:34:19 CET
Created attachment 8147 
Patch 4/7
Comment 4 John Lindgren editbugs 2018-12-01 07:34:55 CET
Created attachment 8148 
Patch 5/7
Comment 5 John Lindgren editbugs 2018-12-01 07:35:48 CET
Created attachment 8149 
Patch 6/7
Comment 6 John Lindgren editbugs 2018-12-01 07:36:13 CET
Created attachment 8150 
Patch 7/7
Comment 7 Git Bot editbugs 2018-12-02 22:36:34 CET
John Lindgren referenced this bugreport in commit c3a8821f9d34d8df8c24610afe599847bc97a788

Fix null pointer dereference with no battery present (Bug #14930).

https://git.xfce.org/panel-plugins/xfce4-battery-plugin/commit?id=c3a8821f9d34d8df8c24610afe599847bc97a788
Comment 8 Git Bot editbugs 2018-12-02 22:36:38 CET
John Lindgren referenced this bugreport in commit 77a9b19d49c3fd4d81d52d9e2b3c5aab51d75fb3

Re-detect battery presence every 30 seconds (Bug #14930).

https://git.xfce.org/panel-plugins/xfce4-battery-plugin/commit?id=77a9b19d49c3fd4d81d52d9e2b3c5aab51d75fb3
Comment 9 Git Bot editbugs 2018-12-02 22:36:41 CET
John Lindgren referenced this bugreport in commit 2417d8ef81c5b7f2d519a90f1a1c67a0a8138047

Reset averages when a battery is removed/added (Bug #14930).

https://git.xfce.org/panel-plugins/xfce4-battery-plugin/commit?id=2417d8ef81c5b7f2d519a90f1a1c67a0a8138047
Comment 10 Andre Miranda editbugs 2018-12-02 22:38:11 CET
Plugin is working as before to me, unfortunately I can't remove my laptop's battery.
Anyway, looks good to me, pushed to master.
Thanks!

Bug #14930

Reported by:
John Lindgren
Reported on: 2018-12-01
Last modified on: 2018-12-02

People

Assignee:
Xfce-Goodies Maintainers
CC List:
1 user

Version

Attachments

Patch 1/7 (18.28 KB, patch)
2018-12-01 07:31 CET , John Lindgren
no flags
Patch 2/7 (3.80 KB, patch)
2018-12-01 07:32 CET , John Lindgren
no flags
Patch 3/6 (11.18 KB, patch)
2018-12-01 07:33 CET , John Lindgren
no flags
Patch 4/7 (1.53 KB, patch)
2018-12-01 07:34 CET , John Lindgren
no flags
Patch 5/7 (2.20 KB, patch)
2018-12-01 07:34 CET , John Lindgren
no flags
Patch 6/7 (7.49 KB, patch)
2018-12-01 07:35 CET , John Lindgren
no flags
Patch 7/7 (1.79 KB, patch)
2018-12-01 07:36 CET , John Lindgren
no flags

Additional information