Repository navigation
Conversation
|
chessing234
left a comment
There was a problem hiding this comment.
Reviewed head faf754cb43203056e885e180b50e0923d9da0ef3.
Reviewed inhibitor identity matching against MainPID, bounded acquisition confirmation, failed-start cleanup, stop error propagation, and indicator refresh. The isolated lid-awake test passed. No actionable defect found. Actual logind authorization and laptop lid behavior still require a Linux session.
|
Not hypothetical: an unrelated Repro on a scratch unit (verified): systemd-run --user --collect --quiet --unit=lid-awake-restarttest \
-p Restart=on-failure -p RestartSec=1 \
systemd-inhibit --what=handle-lid-switch --mode=block \
--who="Restart Test" --why="verify auto-recovery" sleep infinity
kill -TERM "$(pgrep -P "$(systemctl --user show -p MainPID --value lid-awake-restarttest)")"
systemctl --user is-active lid-awake-restarttest # active again, new MainPID, inhibitor re-held
systemctl --user stop lid-awake-restarttest # stays inactive — the off path still winsSuggestion: add
|
|
Thanks for this. The transient-unit inhibitor is a nice, root-free approach. Just a heads-up: there are already two open PRs for the same feature with different designs, so it probably needs a maintainer call on which shape to take:
It might help to note in the description how this one differs (no persistence across reboot, an indicator instead of the power panel, the battery floor). Greptile's point about checking the battery floor right when it's enabled also still seems open. |
|
Thanks for the related PRs. #12882 is the closest overlap: its Power-panel home is a strong fit for a persistent policy, but it needs an always-visible state indicator. This PR is intentionally the transient, per-task form: it resets on reboot and shows the indicator. I do not think #11525's agent-driven guard belongs in this PR; sometimes the desired action is to close the laptop and let it suspend. A maintainer should choose one coherent manual-toggle UI rather than land parallel toggles. |
Closing the lid suspends a laptop unless an external monitor is attached, and stay awake only covers the idle timer, so there is no way to leave a build, SSH session, or remote agent running with the lid shut. omarchy-toggle-lid-awake holds a logind handle-lid-switch inhibitor in a transient user unit. Logind grants it to the active session without a password, and it is gone after a reboot. Closing the lid still runs omarchy-system-lid-close, so the session locks and the panel blanks. It gets a laptop-only indicator next to stay awake and a Trigger > Toggle entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed start or stop now exits non-zero instead of reading as success, and turning it on waits for logind to list the inhibitor, stopping the unit if it never appears. The indicator runs one more status check when a refresh arrives mid-check, instead of dropping it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the inhibitor to the unit's MainPID, since shutdown holds a lid-switch inhibitor under the same Omarchy name. Turning it off now stops the unit without asking first, so a failed is-active query can't pass for an already-stopped unit; only "not loaded" counts as off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET
7f57116 to
381c46d
Compare
|
@cad0p Thanks — adopted as suggested: the unit now runs with |
|
@jandrusk Rebased onto current |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Why
Closing a laptop's lid suspends it unless an external monitor is attached. Stay awake only covers the idle timer, so there's currently no way to leave a build, download, SSH session or remote agent session running with the lid shut, short of editing
logind.conf.What
omarchy toggle lid awake(bin/omarchy-toggle-lid-awake,[toggle|on|off|status]) holds a logindhandle-lid-switchinhibitor in a transient user unit,omarchy-lid-awake.omarchy-system-lid-close, so the session locks and the panel blanks. Only the suspend is skipped.onwaits for logind to list the unit's own inhibitor (matched byMainPID, since other Omarchy commands hold lid-switch inhibitors under the same name) and fails if it never appears. Failed starts and stops exit non-zero.Restart=on-failure,RestartSec=1); an explicit stop still wins.lidAwake.batteryFloorinshell.jsontakes 1–100, or0to disable it. The toggle runs the check immediately on enable, so a laptop already below the floor doesn't stay awake for a poll interval.LidAwakeindicator next to Stay Awake, using the laptop glyph (). It's hidden on machines without a lid (omarchy-hw-laptop) and listed in the indicators manifest options. Its tooltip says when the battery floor turned it off.journalctl --user --follow --unit=omarchy-lid-awake), the way Dictation followsvoxtype status --follow, and re-checks the unit on each entry. A failure, restart, floor stop or manualsystemctl --user stopreaches the bar without polling, and entries queue in the pipe if the shell is busy. The follower starts the first time an indicator sees lid awake on, so a laptop that never uses it runs none, andsetpriv --pdeathsigends it with the shell.omarchy-hw-laptop.Related PRs
Two open PRs take a different shape for the same need, so this needs a maintainer call on one manual-toggle UI rather than landing parallel toggles:
This PR is the transient, per-task form: an independent unit that survives shell restarts, resets on reboot, disarms at the battery floor, and shows its state in the indicators.
Testing
test/shell.d/lid-awake-test.shstubssystemctl,systemd-runandsystemd-inhibit. It covers on, off, toggle, status, idempotence, the restart policy, the immediate floor check, the indicator refresh and journal follower, and bad arguments, plus a non-zero exit when the unit can't start, when logind never lists the unit's own inhibitor (even with another Omarchy lid-switch inhibitor present), and when the unit can't be stopped. It also checks thatoffstill stops the unit when the status query fails.test/shell.d/battery-test.shcovers floor parsing, the discharging-only floor, disabling it, the immediate-check IPC and the alert on every floor stop. The indicator contract fixture covers the tooltips../test/shell: the lid awake, battery, indicator contract and manifest entrypoint tests pass. Seven test files fail, and the same seven fail on unmodifiedquattroon this machine. They need theomarchy-pkgscheckout,omasnap, or a live browser: config, elsewhen-migration, launch-browser, passwordless-grant-lifecycle, screenshot-sanity, snapper, unowned-system-paths.systemd-inhibit --list, the unit re-acquires it after its helper is killed, and a Quickshell instance running the follower received every start, failure, restart and stop entry, including ones logged while it was frozen. Killing that shell with-9took the follower down with it.Why an indicator, not a plugin
This belongs with Stay Awake in the indicators group: it's the lid-closed half of the same question, it's a mode you flip on for a while and off again, and it should stay out of the way until you hover. Third-party plugins can't add to the indicators group, so the standalone widget at https://github.com/benredrew/omarchy-lid-awake is a stopgap: a permanent bar icon, until this lands.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NBknZQb4Lb41uWc7Ne2mET