Skip to content

Subscribe to active power profile changes via Quickshell UPower service - #11856

Closed
EyasDmour wants to merge 1 commit into
omacom:quattrofrom
EyasDmour:event-driven-powerprofiles
Closed

EyasDmour wants to merge 1 commit into
omacom:quattrofrom
EyasDmour:event-driven-powerprofiles

Conversation

@EyasDmour

Copy link
Copy Markdown

Summary

The battery service previously polled the active power profile every two seconds using busctl (and earlier powerprofilesctl) to keep the active profile visible to consumers like the wallpaper and lock screen without requiring the power panel to be open.

Follow up to commit 55799c4 ("Poll the active power profile over D-Bus instead of powerprofilesctl") / PR #11637, which noted:

There is no portable way to subscribe to profile changes from QML; keep them visible to consumers such as the wallpaper service without requiring the power panel to be open.

However, Quickshell's built-in Quickshell.Services.UPower module (already imported in Service.qml) provides a native C++ PowerProfiles singleton that listens directly to D-Bus PropertiesChanged signals on org.freedesktop.UPower.PowerProfiles.

This PR binds activePowerProfile reactively to PowerProfiles.profile, eliminating the 2-second polling timer, subprocess forks, and JSON parsing entirely.

Changes

  • Bind activePowerProfile reactively to PowerProfiles.profile in shell/plugins/services/battery/Service.qml.
  • Remove the 2-second polling Timer, powerProfileReadProcess (busctl), and parseActiveProfile helper.
  • Update test/shell.d/video-background-test.sh assertions to test the event-driven binding.

Benefits

  • Power Efficiency: Eliminates ~43,200 process launches and timer wakeups per day, allowing deeper CPU sleep states on battery.
  • Zero Delays: Immediate signal propagation when switching power profiles.
  • Code Simplification: Net reduction of 38 lines of boilerplate.

Verification

  • Ran ./test/shell.d/video-background-test.sh (pass).
  • Ran ./test/shell.d/powerprofiles-set-test.sh (pass).
  • Ran test/shell.d/battery-test.sh & test/shell.d/power-test.sh (pass).
  • Ran ./test/cli (pass).
  • Tested live instantiation inside quickshell.

The battery service previously polled the active power profile every two
seconds using busctl to keep the state visible to consumers like the
wallpaper and lock screen without requiring the power panel to be open.

Follow up to commit 55799c4 ("Poll the active power profile over D-Bus
instead of powerprofilesctl") / PR omacom#11637, which stated:
> There is no portable way to subscribe to profile changes from QML; keep
> them visible to consumers such as the wallpaper service without requiring
> the power panel to be open.

However, with the help of the troubleshooting AI skill, the agent found that Quickshell's built-in Quickshell.Services.UPower module already
provides a native C++ PowerProfiles singleton that listens directly to
D-Bus PropertiesChanged signals on org.freedesktop.UPower.PowerProfiles.

Bind activePowerProfile directly to PowerProfiles.profile, eliminating the
2-second polling timer, subprocess forks, and JSON parsing entirely.
@EyasDmour

Copy link
Copy Markdown
Author

This is my first commit to a public open source project, don't be nice, be harsh its okay. I need the feedback if you can spare me the time. I honestly feel a little shame sending a commit that's heavily AI-assisted, and I don't even know if this feeling is what I should be feeling or not...

so much drama around AI use, personally, I just try to stay ahead of the curve without rotting my brain by over-relying on AI for code.

@sprajs

sprajs commented Sep 15, 2026

Copy link
Copy Markdown

Cross-linking #10951, opened earlier for the same native-subscription change and now updated for current quattro. Both remove the two-second reader and use PowerProfiles.profile; #10951 compares PowerProfile.PowerSaver directly instead of converting the enum back to a string.

#10951 also has contributor-provided live hardware measurements and profile-change validation. Those measurements compare against the original Python poll, not the subsequently merged busctl reader. Linking the work so reviewers can consider the implementations and existing evidence together.

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #10951, which covers the same power profile native service. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

@bjarneo bjarneo closed this Sep 21, 2026
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.

3 participants