Conversation
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.
|
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. |
|
Cross-linking #10951, opened earlier for the same native-subscription change and now updated for current #10951 also has contributor-provided live hardware measurements and profile-change validation. Those measurements compare against the original Python poll, not the subsequently merged |
|
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. |
Summary
The battery service previously polled the active power profile every two seconds using
busctl(and earlierpowerprofilesctl) 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:
However, Quickshell's built-in
Quickshell.Services.UPowermodule (already imported inService.qml) provides a native C++PowerProfilessingleton that listens directly to D-BusPropertiesChangedsignals onorg.freedesktop.UPower.PowerProfiles.This PR binds
activePowerProfilereactively toPowerProfiles.profile, eliminating the 2-second polling timer, subprocess forks, and JSON parsing entirely.Changes
activePowerProfilereactively toPowerProfiles.profileinshell/plugins/services/battery/Service.qml.Timer,powerProfileReadProcess(busctl), andparseActiveProfilehelper.test/shell.d/video-background-test.shassertions to test the event-driven binding.Benefits
Verification
./test/shell.d/video-background-test.sh(pass)../test/shell.d/powerprofiles-set-test.sh(pass).test/shell.d/battery-test.sh&test/shell.d/power-test.sh(pass)../test/cli(pass).quickshell.