Skip to content

Hide Hibernate when the kernel will not accept the request - #7779

Merged
omarchybot merged 1 commit into
quattrofrom
fix/issue-7730
Oct 31, 2026
Merged

omarchybot merged 1 commit into
quattrofrom
fix/issue-7730

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

omarchy-hibernation-available checked that /sys/power/image_size exists, that non-zram swap exceeds the hibernation image size, and that /etc/mkinitcpio.conf.d/omarchy_resume.conf exists — everything except whether the kernel will take a hibernation request. All three hold on a machine where hibernation is disabled, so the system.hibernate row was shown, systemctl hibernate ran detached with its output on /dev/null, and from the user's side clicking Hibernate did nothing at all.

The kernel lists disk in /sys/power/state exactly while hibernation_available() holds — no nohibernate, no lockdown, no secretmem, no active CXL memory — and that same predicate is what makes /sys/power/disk read [disabled] and rejects every write to it with -EPERM. The probe now requires that token, which is also what logind asks before answering CanHibernate.

Reproduced on a disposable VM without simulating anything: raising the running kernel's lockdown to integrity turned /sys/power/state from freeze mem disk into freeze mem, /sys/power/disk into [disabled], and CanHibernate from challenge into na, 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_size that 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_*_PATH override the way omarchy-power-present does, which is what lets the new test/shell.d/hibernation-available-test.sh build a kernel that refuses.

Two wider gaps are deliberately left: the probe trusts that omarchy_resume.conf exists rather than that resume= reached the running kernel, so the row appears between omarchy hibernation setup and 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.

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates hibernation detection so the menu hides Hibernate when the kernel rejects hibernation.

Changes:

  • Requires the kernel’s disk sleep 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.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

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 integrity dropped disk from /sys/power/state, turned /sys/power/disk to [disabled] and logind's CanHibernate to na. Under those conditions quattro's omarchy-hibernation-available still exits 0, so the Hibernate row would show and do nothing; this branch exits 1. With the fix reverted, the new test/shell.d/hibernation-available-test.sh fails at "hibernation is unavailable when the kernel offers no disk sleep state". On the head, the new test (9 checks) and ./test/cli pass on the worker. bin/omarchy-hibernation-available is unchanged on quattro since this branch was cut, and no other open pull request touches it.

Second opinion from Codex Medium found no defects. It traced disk in /sys/power/state to the same hibernation_available() check that the kernel's hibernate path refuses on, and judged the image_size validation and path overrides proportionate. That matches this review, but the two are not guaranteed to be independent. Its one note: disk rules out the blockers it names, but it cannot promise a hibernation will then succeed.

This fixes #7730 and now waits on the maintainer.

@omarchybot omarchybot added ready Good to merge and removed ready Good to merge labels Sep 28, 2026
@omarchybot
omarchybot merged commit c97617b into quattro Oct 31, 2026
4 checks passed
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
berenddeboer pushed a commit to berenddeboer/omarchy that referenced this pull request Nov 6, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-hibernation-available returns success when the kernel has hibernation disabled, making the Hibernate menu entry a silent no-op

3 participants