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
Created attachment 8145 Patch 2/7
Created attachment 8146 Patch 3/6
Created attachment 8147 Patch 4/7
Created attachment 8148 Patch 5/7
Created attachment 8149 Patch 6/7
Created attachment 8150 Patch 7/7
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
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
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
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!