Skip to content

Read and set the power profile over D-Bus instead of powerprofilesctl - #12552

Open
shrijit37 wants to merge 7 commits into
omacom:quattrofrom
shrijit37:power-profiles-over-dbus
Open

shrijit37 wants to merge 7 commits into
omacom:quattrofrom
shrijit37:power-profiles-over-dbus

Conversation

@shrijit37

@shrijit37 shrijit37 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

powerprofilesctl is a PyGObject script (#!/usr/bin/env python3). Under a shell whose PATH leads with a Homebrew or mise python, the shebang resolves to a python without gi and the command dies with ModuleNotFoundError: gi and no output. The battery dropdown spawns it through Quickshell's process PATH — the list comes back empty, the POWER PROFILE section renders no buttons, and setting a profile does nothing. #11637 already moved the battery service's poll to busctl ... ActiveProfile; the panel and menu still route through the Python CLI.

Fix

Read and set the power profile directly over D-Bus, no Python involved:

  • bin/omarchy-powerprofiles-list reads the daemon's Profiles and ActiveProfile properties via busctl --json=short ... get-property, with jq extracting the names. It still emits name\t0|1 per line, so the panel's highlight and index logic are unchanged.
  • bin/omarchy-powerprofiles-set sets ActiveProfile via busctl set-property. The UPower autodetect read is unchanged.
  • shell/plugins/menu/Menu.qml reads the active profile for its provider the same way and lists through the D-Bus-backed script.
  • shell/plugins/panels/power/Panel.qml resets the profile list on an empty payload and re-kicks the query on the next open, so a transient failure can't freeze the buttons.

Evidence

On a T2 MacBook running Arch, where Homebrew's python shadows the system one under the panel's PATH:

$ PATH="/home/linuxbrew/.linuxbrew/bin:/usr/bin" powerprofilesctl get
ModuleNotFoundError: No module named 'gi'

The equivalent busctl reads always answer — the daemon's properties are plain D-Bus.

Tests

test/shell.d/powerprofiles-set-test.sh fakes the D-Bus daemon instead of the Python CLI: a stub busctl serves Profiles, ActiveProfile, and UPower OnBattery and logs set-property calls, so every existing assertion (state files, calls log, autodetect, init, defaults) keeps running against the new transport. test/shell.d/power-test.sh asserts the panel's reset/retry behavior. video-background-test.sh's existing busctl ActiveProfile assertion is untouched.

Supersedes

This removes the dependency on the Python CLI, so the shebang-patch approach (install/config/fix-powerprofilesctl-shebang.sh, reverted by every power-profiles-daemon upgrade — #11031) no longer applies to power profiles, and supersedes the re-apply direction of #11097 by not editing a package-owned file. Related: #8184, #8596.

Fixes #8596

@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: the switch from powerprofilesctl to busctl + jq matches the power-profiles-daemon 0.30 D-Bus interface and systemd 262 busctl output. Profile order, the active marker, set semantics, error exits and polkit authorization are unchanged. One small behavior change in Panel.qml is described below, along with a note on test coverage.

Path Base (powerprofilesctl) Head (busctl)
omarchy-powerprofiles-list, --active-state, menu provider reference output byte-identical in 5 synthetic daemon states (3- and 2-profile systems, each profile active)
omarchy-powerprofiles-set reference exit, final profile, state files identical in 5 scenarios (explicit, AC and battery defaults)
Profile order daemon order, reversed by powerprofilesctl list, reversed back by tac daemon order read directly (power-saver, balanced, performance)
Set denied or daemon missing nonzero exit, no state written nonzero exit, no state written

The legacy net.hadess.PowerProfiles name is registered and D-Bus-activatable in 0.30, is still present on current upstream main, and the battery service already polls it. busctl defaults to the system bus, so the missing --system in Menu.qml targets the same bus. jq and systemd are base packages.

Panel.qml: an empty refresh now clears the profile buttons

Base kept the last good profile list when a refresh returned nothing (the removed comment: "so the buttons don't blink out"). Base already re-queried on every open and every 5 s while the panel is open, so a failed read did not leave the list stuck.

panel open, list shown ──► one refresh returns empty (daemon restart, failed read)
  base: keep last list ─────────────► next 5 s poll replaces it
  head: profiles = [], index = 0 ───► row empty until next 5 s poll;
                                      keyboard cursor returns to first profile

The added if (profiles.length === 0) profilesProc.running = true runs right after refresh() has started the same process. In Quickshell 0.3.1 Process, this does not start a second process. It queues one more run that starts as soon as the current one finishes, so on an open with an empty list, the query runs twice in a row. It does not add recovery on a later open (base already had that), and it does nothing for a later failed poll while the panel stays open.

Impact: small. With the busctl path, empty payloads should be rare. When one happens while the panel is open, the power-profile row disappears for up to about 5 s instead of staying usable. This follows from source; it was not observed on a desktop.

Suggested change: keep the existing last-good-list guard and drop this hunk (and its two regex assertions in power-test.sh), keeping the PR to the transport change. If a specific stuck state motivated it, describing that state would allow handling it directly, for example by clearing only after repeated empty payloads.

Optional test improvement: the new fake busctl in powerprofiles-set-test.sh matches only the verb and property keywords, so a wrong bus name, object path, interface, s signature or a missing --json=short would still pass. In a sandboxed run, the head test file against the base scripts with a working powerprofilesctl fake passed 11 of 12 assertions, and only the rg 'powerprofilesctl' source grep failed. Having the fake log its full argv and asserting the exact get-property/set-property lines for one list and one set call would tie the test to the new transport.


Review information

Test scope: source review of the head 1047b804 against its merge-base, power-profiles-daemon 0.30 and current main, systemd v262 busctl, and Quickshell v0.3.1 Process. Sandboxed runs of powerprofiles-set-test.sh on head and base, plus base/head output comparisons, used synthetic busctl and powerprofilesctl fakes built from upstream source. No real daemon, system bus, polkit or hardware was used. power-test.sh was not executed (its new assertions were checked by source). Panel behavior was not observed in a running desktop session.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@jandrusk

Copy link
Copy Markdown

Good fix for the #!/usr/bin/env python3 → wrong python / missing gi failure mode. CONFLICTING against current quattro — rebase and this should be ready. Tests swapping the fake to busctl look fine.

busctl --system against net.hadess.PowerProfiles replaces the PyGObject
CLI whose env-python3 shebang breaks under Homebrew/mise PATHs. Keeps the
battery-service IPC refresh from omacom#15027 and the panel's last-good guard.
@shrijit37
shrijit37 force-pushed the power-profiles-over-dbus branch from 1047b80 to 09e23c8 Compare October 14, 2026 13:35
@omarchybot omarchybot added bug Something isn't working and removed enhancement New feature or request labels Oct 14, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this. I read the change at 09e23c8 against quattro and compared it with the other open work on the same bug; nothing was run on a worker, for the reason below.

The ModuleNotFoundError: gi failure is real on quattro today: the install-time shebang rewrite in install/config/fix-powerprofilesctl-shebang.sh is undone by every power-profiles-daemon upgrade (#11031). Two other open pull requests address the same cause:

Not calling Python at all is a reasonable design on its own merits, but that is a choice between approaches rather than a defect in the others, so it is left to the maintainer. This also overlaps #8712 (skip the profile calls when the daemon is down, #8596): both rewrite the current-profile command in shell/plugins/menu/Menu.qml, so whichever lands second will need a rebase.

Codex Medium reviewed the same comparison and also concluded that #11097 takes precedence by age, that #14737 makes both moot, and that #11097 conflicts with #14737 (it modifies the script #14737 deletes). That review read this session's notes, so its agreement is not guaranteed to be independent. This one now waits on the maintainer to decide between the three.

omarchybot and others added 4 commits November 1, 2026 12:43
The D-Bus address and the jq that parses it now live only in the list script, instead of being repeated inline in the menu provider.

Co-Authored-By: islam <islamimad66@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The list check above it runs the script against the fake busctl, which is what shows it reads D-Bus; quattro dropped tests that only read source text in omacom#16334.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…filesctl

The Omarchy build of power-profiles-daemon (omacom#14737) ships powerprofilesctl with a fixed /usr/bin/python3 shebang, so the PATH failure the comment named no longer happens; the PyGObject shutdown crash from omacom#8596 still does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

Power-profile reads and writes now use D-Bus instead of powerprofilesctl.

  • Power profile lists now get names and selection from D-Bus.
  • Power profile choices now go straight to the daemon.

No new actionable issues were found.

Reviews (2) · Last reviewed commit: "Read the power profiles once for the men..." · Reviewed by Greptile

Comment thread shell/plugins/menu/Menu.qml Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

I looked at this again because #14737 has merged since my last comment. That changes part of the picture: Omarchy's own omarchy-power-profiles-daemon build ships powerprofilesctl with a fixed /usr/bin/python3 shebang, so the ModuleNotFoundError: gi failure this description leads with no longer happens on a stock install, and #11097 has nothing left to fix. The crash in #8596 is still there, though: powerprofilesctl is a PyGObject script that sometimes segfaults or aborts at interpreter shutdown (python/cpython#124619), and on quattro it is still started by omarchy-powerprofiles-list, omarchy-powerprofiles-set and the menu's power-profile provider. This pull request is the only open one that removes every remaining caller, so it is now the one I'd bring forward, ahead of #11097 and #8712. I've linked it to #8596.

Pushed to your branch (fast-forward, no force):

  • A merge of quattro, which had conflicted in test/shell.d/powerprofiles-set-test.sh. Remove tests that only read source text #16334 removed the source-grep checks there, and the resolution keeps that removal and keeps your D-Bus list test.
  • The menu now reads the active profile through omarchy-powerprofiles-list --active-state, so the D-Bus address and the jq parsing live only in the list script. That idea comes from Skip powerprofilesctl when daemon is down #8712, so the commit credits @Elshayib as co-author.
  • Removed the rg -q 'powerprofilesctl' assertion, since Remove tests that only read source text #16334 removed tests that only read source. The list test above it already shows the script reads D-Bus by running it.
  • Updated the comment in omarchy-powerprofiles-list so it gives the shutdown crash as the reason, not the shebang.

Checked on a disposable Omarchy ISO worker (omarchy-power-profiles-daemon 0.30-3) at d147c13:

  • With a logging powerprofilesctl wrapper on PATH, run from the desktop session, I ran list, list --active-state, set to power-saver, the menu provider, set to balanced, and the menu provider again. quattro started the Python CLI 10 times. This branch started it 0 times, with identical output, and the daemon's ActiveProfile followed each set. With the change reverted it was 10 again.
  • A stopped daemon is started by the busctl read (D-Bus activation). With the daemon masked, the list is empty and set exits 1 with "Power profile is not available", with no core dump.
  • Test results: powerprofiles-set-test 9/9, menu-test 110/110, power-test 20/20, shell-idle-spawn-test 1/1, ./test/cli green, and CI green. In the full ./test/shell run, 5 files fail identically on quattro and on this branch, and none of them touch power profiles.
  • The crash itself did not trigger in 13,000 looped runs of quattro's path. That matches powerprofilesctl crashes (SIGABRT) when power-profiles-daemon is masked — hit on every power event with TLP #8596: it is intermittent. The evidence that removing the CLI calls fixes it is the cores in powerprofilesctl crashes (SIGABRT) when power-profiles-daemon is masked — hit on every power event with TLP #8596, not a reproduction here.
  • The power panel draws only when UPower reports a battery, so the worker VM could not show it. Its own command, omarchy-powerprofiles-list --active-state, gave the same output on both trees.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the full diff against quattro. Neither found a defect. Both confirmed that the daemon's Profiles order matches what tac produced before, and that no caller of powerprofilesctl remains in bin/ or shell/. They could read this session's notes, so their agreement isn't guaranteed to be independent.

Waiting on you, @shrijit37: please update the description to match the branch. It describes a Panel.qml reset/retry and power-test.sh assertions that aren't in the diff, and its Problem section is about the shebang failure that #14737 has since fixed. The reason this change still matters is the shutdown crash in #8596. After that, it goes to the maintainer.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 15, 2026
quattro's omacom#18745 added omarchy-powerprofiles-floor with a test that needs a powerprofilesctl get mock; this branch had removed the mock since list and set no longer call the CLI. Keep the mock with only get, so list and set still cannot pass through it, and keep both tests.
--active-state already gives every profile and which is active, so the provider no longer runs the list twice, four D-Bus reads where two do.
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

quattro had moved on and this no longer merged cleanly, so I brought it up to date and checked it again.

Pushed to your branch (fast-forward, no force):

  • A merge of quattro (81d11dc). It conflicted in test/shell.d/powerprofiles-set-test.sh, where Give Snapdragon power profiles a CPU floor for bursty work #18745 added a test for the new omarchy-powerprofiles-floor. That test needs a powerprofilesctl get mock, which this branch had removed. The resolution keeps the mock with only get, so list and set still can't pass by falling back to the CLI, and it keeps both tests.
  • The menu's power-profile provider now reads omarchy-powerprofiles-list --active-state once and builds the rows from that one read, instead of calling the list twice (c7d84ac). That was Greptile's point on Menu.qml:331, and it was right.

Checked on a disposable Omarchy ISO worker (omarchy-power-profiles-daemon 0.30-9, shell running this branch) at c7d84ac:

  • I put a logging powerprofilesctl wrapper on PATH and, from the desktop session, ran list, list --active-state, set to power-saver, the menu provider, set to balanced, and the provider again. quattro started the Python CLI 10 times. This branch started it 0 times, with identical output, and the daemon's ActiveProfile followed each set. With the change reverted it was 10 again.
  • A stopped daemon is started by the busctl read. With the daemon masked, the list is empty and set exits 1 with "Power profile is not available", with no core dump.
  • Test results: powerprofiles-set-test 10/10, menu-test 115/115, power-test 25/25, shell-idle-spawn-test 1/1, and ./test/cli green. In the full ./test/shell run, the same 5 unrelated files fail on quattro and on this branch. CI's test job failed in dropdown-test.sh ("keyboard walk stalled at 3"). That test only loads shell/Ui/Dropdown.qml and its fixtures, which this branch doesn't change, and it passed in the worker's full run. It needs a re-run.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the merge resolution and the new menu line. Neither found a defect. They could read this session's notes, so their agreement isn't guaranteed to be independent. They disagreed on one thing: #18745's omarchy-powerprofiles-floor (a root service, installed only on Snapdragon) still runs powerprofilesctl get on every profile change and login. Codex would convert it here too. muse-wonder would leave it for a follow-up, since it arrived after this pull request and a failed read there falls back to no floor, not a broken service. I've left it alone; whether it belongs in this pull request is the maintainer's call.

Still waiting on you, @shrijit37: the description still describes a Panel.qml reset/retry and power-test.sh assertions that aren't in the diff, and it leads with the shebang failure that #14737 fixed. The reason this change matters now is the shutdown crash in #8596. Once the description matches the branch and CI passes on a re-run, it goes to the maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

powerprofilesctl crashes (SIGABRT) when power-profiles-daemon is masked — hit on every power event with TLP

4 participants