Skip to content

Emit D-Bus PropertiesChanged signal when battery charge state changes - #468

Open
abebinder wants to merge 1 commit into
linuxmint:masterfrom
abebinder:charging_fix
Open

Emit D-Bus PropertiesChanged signal when battery charge state changes#468
abebinder wants to merge 1 commit into
linuxmint:masterfrom
abebinder:charging_fix

Conversation

@abebinder

@abebinder abebinder commented Aug 22, 2026

Copy link
Copy Markdown

TLDR

Fixes linuxmint/cinnamon#13686 by making it so the PropertiesChanged D-Bus signal is emitted whenever the battery "state" changes which causes an immediate update to the power applet message.

Before

We use watch -n 1 cat /sys/class/power_supply/BAT0/status to view the live state of the battery. When we plug in adapter, battery transitions to "not charging" and then quickly to "charging". the applet message transitions to "not charging" and will not update to "charging until the next percentage tick.

2026-08-22.11-56-21.mp4

After

We use watch -n 1 cat /sys/class/power_supply/BAT0/status to view the live state of the battery. When we plug in adapter, battery state transitions to "not charging" and then quickly to "charging" and applet message mirrors these transitions.

2026-08-22.11-53-15.mp4

Problem Description

When you plug in an adapter, for a brief moment the battery "state" will be "pending-charge" (as reported by upower) as the system decides if this adapter being plugged in should allow the battery to charge. This resolves to message "not charging" on the applet.

However, the battery state will usually quickly transition to "charging" once the system accepts the adapter as viable to allow the battery to charge. However, the message on the power applet will remain as "not charging" until the next percentage tick.

The reason for this is because the power applet message only gets updated when certain D-Bus properties change and a PropertiesChanged signal is emitted (via g_dbus_interface_skeleton_flush), and the properties previously only included "percentage" and "icon".

The icon for "pending-charge" is the same as "charging" so a transition between pending-charge and charging does not result in an update to the applet. Thus it waits for percentage to tick up before changing.

Summary of Fix

We add the battery "state" as a D-Bus property and set it on the skeleton whenever it changes, then flush the skeleton which emits the PropertiesChanged signal. This triggers the power applet to refresh its display immediately.

Companion PR in cinnamon: linuxmint/cinnamon#13945 (declares the new State property in the D-Bus interface XML)

@abebinder abebinder changed the title Emit PropertiesChanged when battery charge state changes Emit D-Bus PropertiesChanged signal when battery charge state changes Aug 22, 2026
@abebinder
abebinder marked this pull request as ready for review August 22, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Power Applet: Battery icon shows charging but text label says "Not charging"

1 participant