Repository navigation
Hide Hibernate when the kernel will not accept the request - #7779
Conversation
omarchy-hibernation-available measured swap and looked for the resume hook, but never asked the kernel whether it would take a hibernation request. A machine where hibernation is disabled -- lockdown, nohibernate, secretmem, an active CXL device -- still got the Hibernate menu row, and selecting it ran `systemctl hibernate` detached with its output on /dev/null, so logind's refusal was invisible and the machine simply stayed awake. The kernel lists "disk" in /sys/power/state exactly while it will accept the request; the same predicate is what makes /sys/power/disk read [disabled]. Raising a test machine's lockdown to integrity reproduced both readings and the false success. An image size that exists but does not read was a second way to say yes: named bare in the arithmetic comparison it counts as zero, and any swap at all beats zero. The sysfs, swaps and resume-config paths take an override the way omarchy-power-present does, so the test can construct a kernel that refuses. 🤖 Generated by Opus 5 in Claude Code. Reviewed by Codex XHigh. Co-Authored-By: Codex XHigh <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates hibernation detection so the menu hides Hibernate when the kernel rejects hibernation.
Changes:
- Requires the kernel’s
disksleep state and a readable numeric image size. - Adds configurable paths and comprehensive availability tests.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bin/omarchy-hibernation-available |
Strengthens kernel capability checks and adds testable path overrides. |
test/shell.d/hibernation-available-test.sh |
Covers supported, disabled, malformed, and insufficient-resource scenarios. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Verified by reproduction on a disposable Omarchy VM, at 95e90e0. On a machine where hibernation works (8 GiB swapfile, zram, resume config in place), raising the running kernel's lockdown to Second opinion from Codex Medium found no defects. It traced This fixes #7730 and now waits on the maintainer. |
omarchy-hibernation-available measured swap and looked for the resume hook, but never asked the kernel whether it would take a hibernation request. A machine where hibernation is disabled -- lockdown, nohibernate, secretmem, an active CXL device -- still got the Hibernate menu row, and selecting it ran `systemctl hibernate` detached with its output on /dev/null, so logind's refusal was invisible and the machine simply stayed awake. The kernel lists "disk" in /sys/power/state exactly while it will accept the request; the same predicate is what makes /sys/power/disk read [disabled]. Raising a test machine's lockdown to integrity reproduced both readings and the false success. An image size that exists but does not read was a second way to say yes: named bare in the arithmetic comparison it counts as zero, and any swap at all beats zero. The sysfs, swaps and resume-config paths take an override the way omarchy-power-present does, so the test can construct a kernel that refuses. 🤖 Generated by Opus 5 in Claude Code. Reviewed by Codex XHigh. Co-authored-by: Codex XHigh <[email protected]> (cherry picked from commit c97617b)
omarchy-hibernation-availablechecked that/sys/power/image_sizeexists, that non-zram swap exceeds the hibernation image size, and that/etc/mkinitcpio.conf.d/omarchy_resume.confexists — everything except whether the kernel will take a hibernation request. All three hold on a machine where hibernation is disabled, so thesystem.hibernaterow was shown,systemctl hibernateran detached with its output on/dev/null, and from the user's side clicking Hibernate did nothing at all.The kernel lists
diskin/sys/power/stateexactly whilehibernation_available()holds — nonohibernate, no lockdown, no secretmem, no active CXL memory — and that same predicate is what makes/sys/power/diskread[disabled]and rejects every write to it with-EPERM. The probe now requires that token, which is also what logind asks before answeringCanHibernate.Reproduced on a disposable VM without simulating anything: raising the running kernel's lockdown to
integrityturned/sys/power/statefromfreeze mem diskintofreeze mem,/sys/power/diskinto[disabled], andCanHibernatefromchallengeintona, while the old probe still exited 0. On that machine before the change — 8 GiB swapfile at priority 0, zram at 100, resume config in place — old and new both exit 0.A second way to say yes goes with it: an
image_sizethat exists but does not read is worth zero to the arithmetic comparison, and any swap at all beats zero.The sysfs, swaps and resume-config paths take an
OMARCHY_*_PATHoverride the wayomarchy-power-presentdoes, which is what lets the newtest/shell.d/hibernation-available-test.shbuild a kernel that refuses.Two wider gaps are deliberately left: the probe trusts that
omarchy_resume.confexists rather than thatresume=reached the running kernel, so the row appears betweenomarchy hibernation setupand the reboot it asks for; and it sums every disk swap while the kernel writes its image to one. Both deserve their own change.Fixes #7730.