Skip to content

Keep the powerprofilesctl shebang fix applied across daemon upgrades (#11031) - #11097

Open
sandmor wants to merge 2 commits into
omacom:quattrofrom
sandmor:t3code/address-issue-11031
Open

Keep the powerprofilesctl shebang fix applied across daemon upgrades (#11031)#11097
sandmor wants to merge 2 commits into
omacom:quattrofrom
sandmor:t3code/address-issue-11031

Conversation

@sandmor

@sandmor sandmor commented Sep 10, 2026

Copy link
Copy Markdown

Fixes #11031.

Problem

install/config/fix-powerprofilesctl-shebang.sh rewrote /usr/bin/powerprofilesctl's shebang to #!/bin/python3 exactly once at install time. Every power-profiles-daemon upgrade restored the packaged #!/usr/bin/env python3 and silently undid the fix. On a PATH where mise supplies python3, the CLI then dies with ImportError inside Omarchy's power profile callers (omarchy-powerprofiles-set, omarchy-powerprofiles-list, the Quickshell menu and battery service).

Fix

  • default/libalpm/hooks/70-omarchy-powerprofilesctl-shebang.hook — a new ALPM post-transaction hook firing on Install/Upgrade of power-profiles-daemon (no AbortOnFail), Execs the packaged fix script. The fix is durable from this point forward.
  • install/config/fix-powerprofilesctl-shebang.sh — still the single source of truth; now guards on the exact packaged shebang so an already-fixed client costs nothing and needs no elevation, and uses sudo only when not already root.
  • migrations/1789023127.sh — repairs installs whose upgrade already reverted the fix (the hook alone only helps future upgrades). Idempotent: a second user re-runs it without a prompt once the machine is fixed.

Companion PR: omacom/omarchy-pkgs ships the new hook file in the omarchy and omarchy-dev PKGBUILDs (config-test.sh asserts that pairing once the omarchy-pkgs checkout resolves).

Tests

  • New test/shell.d/powerprofiles-shebang-hook-test.sh (8 ok): hook trigger/shape per pacman-hooks(5), rewrite, idempotency, foreign shebang preserved, missing file tolerated, elevation stubbed end-to-end.
  • Also cleans up a broken-environment test flake: agent-usage-* collector loaders stopped writing bin/__pycache__, and locate-test.sh tolerates such caches when scanning bin/install/migrations (separate commit, same PR).
  • ./test/shell → 237/237, ./test/cli → 112/112.

agent-usage scanner tests import collectors via SourceFileLoader, which
writes a stray bin/__pycache__ next to the collector. That cache then makes
locate-test fail when it reads bin/, install/, and migrations/ as UTF-8.

Stop the loaders from writing bytecode, and make the locate scan skip
__pycache__ and undecodable files so a stray cache can never break it again.
The install-time rewrite of /usr/bin/powerprofilesctl to #!/bin/python3 ran
once and every power-profiles-daemon upgrade restored the packaged
#!/usr/bin/env python3 shebang, so each upgrade silently undid it. Where
mise supplies python3 on PATH, the CLI then dies with ImportError inside
Omarchy's power profile callers.

Ship an ALPM hook that re-applies the fix on Install/Upgrade of
power-profiles-daemon, wire a migration for installs whose upgrade already
reverted the fix, and keep the single source of truth in the install script
that now skips elevation for already-fixed clients.

Closes omacom#11031
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.

fix-powerprofilesctl-shebang runs only at install time, so every power-profiles-daemon upgrade silently reverts it

1 participant