Skip to content

components/batterycontrol: React to D-Bus service (un)register events

Original commit message(s)

  • components/batterycontrol: React to D-Bus service (un)register events

Previously, the "Power and Battery" applet only checked for the presence of PowerDevil's D-Bus services once when it starts up. This appears to (mostly?) work for applets embedded in a panel, but does not work for applets on the desktop itself. Likely there's a timing issue and applets on the desktop start sooner than PowerDevil will advertise its services.

A better way to work is for the applet to monitor the bus for when the relevant services appear or disappear. When observing a service registered or unregistered event, the applet gets set up accordingly.

This fixes the race condition for one out of three applet parts (battery state) but does not fix power profiles & inhibitions; these were fixed separately in the powerdevil repository directly via commit 8e698dbc.

  • components/batterycontrol: Use m_ prefix for all member variables

The odd one out, namesMonitor, should use the common prefix like all other member variables in BatteryControlModel do.

Reason for the change

As described in the main commit. This MR is a follow-up to (and completes the fix from) powerdevil!425 (merged) (CC @meven who reviewed that one).

Test plan

  • Add a "Power and Battery" widget to your desktop (directly, not in the panel)
  • Log out and back in

Before the change, depending on your system's startup timing (but very likely), power profiles and inhibitions aren't shown and even battery information might be missing.

After the change, startup timing does not matter and the applet will always show the right info. Restarting the PowerDevil service will temporarily make it disappear, and bring it back up with any changes that may have happened in the meantime.

Screenshots

BUG: 488915 has a great correct/incorrect comparison.

Bugs fixed

BUG: 488915 BUG: 489003 CCBUG: 492859 CCBUG: 492945

Merge request reports