Automatically switch to power-saver profile on low battery with a hook#4942
Automatically switch to power-saver profile on low battery with a hook#4942pomartel wants to merge 13 commits intobasecamp:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an automatic “switch to power-saver on low battery” mechanism for laptop installs by introducing a new systemd user timer/service and the corresponding script, plus wiring it into both fresh installs and migrations.
Changes:
- Add
omarchy-powerprofile-low-batteryscript that switches topower-saverwhen discharging below a threshold. - Add systemd user
.service+.timerto run the check every 30 seconds. - Enable/install the timer on first run and via a migration for existing users.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| migrations/1772383152.sh | Copies the new systemd user units into ~/.config/systemd/user and enables the timer on laptops. |
| install/first-run/battery-monitor.sh | Enables the new low-battery power-saver timer during first-run setup on battery-powered devices. |
| config/systemd/user/omarchy-powerprofile-low-battery.timer | Defines the 30s systemd user timer for low-battery checks. |
| config/systemd/user/omarchy-powerprofile-low-battery.service | Defines the systemd user oneshot service that runs the low-battery check script. |
| bin/omarchy-powerprofile-low-battery | Implements the low-battery detection + profile switching logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
We could simplify it further by hooking this up with the new |
|
Now that I think about it, maybe sole responsability of Or maybe I'm overthinking this! 🫠 |
|
I think default behavior remains as-is, but we should only have one hook. I'm fine having a hook that's called as often as this, though, but then we need to integrate the work from #4945 in that approach. |
|
@dhh Here are the changes I made:
It's a bit more changes than what you asked for but I think it's more robust. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This is too much. I don't want the default implementation in a hook. Hooks are exclusively for extending the default setup with user-configured features. But the main battery warning needs to be in Omarchy proper still. |
|
@dhh Putting the battery warning in a hook would have allowed users to modify the default threshold (10%) or remove the notification altogether. But if you prefer it not to be user-configurable then I rolled back that change. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
UPDATE: I rewrote the PR to use a hook instead. Less code, cleaner approach.
The default behaviour for laptops is to use
performancemode when plugged in andbalancedwhen unplugged. With this PR, we add a hook that would automatically switch topower-saveron low battery (20% as the default).