Add a power-source-change hook#5653
Open
pomartel wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new power-source-change hook that runs after omarchy-powerprofiles-set, and updates the udev-triggered systemd-run invocation to provide a usable environment (HOME, OMARCHY_PATH, PATH) for hook execution.
Changes:
- Add
omarchy-hook power-source-change "$action"invocation toomarchy-powerprofiles-set - Update udev rules generation to pass
HOME,OMARCHY_PATH, andPATHinto the systemd-run unit - Add a migration to re-apply the updated udev rule generation
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| migrations/1778159545.sh | Re-sources the udev rule generation script so existing installs get updated env passing |
| install/config/powerprofilesctl-rules.sh | Extends generated udev rules to set env vars for the transient unit |
| bin/omarchy-powerprofiles-set | Triggers the new power-source-change hook after applying the selected profile |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+7
| run_path="$omarchy_path/bin:/usr/local/sbin:/usr/local/bin:/usr/bin" | ||
|
|
||
| cat <<EOF | sudo tee "/etc/udev/rules.d/99-power-profile.rules" | ||
| SUBSYSTEM=="power_supply", ATTR{type}=="Mains", RUN+="/usr/bin/systemd-run --no-block --collect --unit=omarchy-power-profile --property=After=power-profiles-daemon.service $HOME/.local/share/omarchy/bin/omarchy-powerprofiles-set" | ||
| SUBSYSTEM=="power_supply", ATTR{type}=="USB", RUN+="/usr/bin/systemd-run --no-block --collect --unit=omarchy-power-profile --property=After=power-profiles-daemon.service $HOME/.local/share/omarchy/bin/omarchy-powerprofiles-set" | ||
| SUBSYSTEM=="power_supply", ATTR{type}=="Mains", RUN+="/usr/bin/systemd-run --no-block --collect --unit=omarchy-power-profile --setenv=HOME=$HOME --setenv=OMARCHY_PATH=$omarchy_path --setenv=PATH=$run_path --property=After=power-profiles-daemon.service $omarchy_path/bin/omarchy-powerprofiles-set" | ||
| SUBSYSTEM=="power_supply", ATTR{type}=="USB", RUN+="/usr/bin/systemd-run --no-block --collect --unit=omarchy-power-profile --setenv=HOME=$HOME --setenv=OMARCHY_PATH=$omarchy_path --setenv=PATH=$run_path --property=After=power-profiles-daemon.service $omarchy_path/bin/omarchy-powerprofiles-set" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It would be useful to have a hook that triggers on power source change. I personally have two use cases:
The main change besides adding the hook to
omarchy-powerprofile-setis that we have to set theHOME,PATHandOMARCHY_PATHin the UDEV rule and run it as the user instead of root to avoid privileges escalation.If you like the idea, I could also add sample hooks.