From 0656b075bdeb512872a9eebedc8d4646f291925e Mon Sep 17 00:00:00 2001 From: manuaudio Date: Mon, 28 Sep 2026 11:26:44 -0700 Subject: [PATCH] Drop the resume kernel parameters when removing hibernation omarchy-hibernation-setup writes /etc/limine-entry-tool.d/resume.conf with resume= and resume_offset=, but removal left it behind, so the next boot image still told the kernel to resume from a deleted swapfile. Setup only writes that file when it is missing, so setting hibernation up again kept the old offset while the new swapfile sat elsewhere, and resume silently lost the session. Removal now deletes the file before regenerating the boot image. Fixes #13583 Co-Authored-By: Claude Opus 5.5 --- bin/omarchy-hibernation-remove | 8 +++++++ test/shell.d/hibernation-remove-test.sh | 32 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 test/shell.d/hibernation-remove-test.sh diff --git a/bin/omarchy-hibernation-remove b/bin/omarchy-hibernation-remove index f06396b55fe..2306f5d3a64 100755 --- a/bin/omarchy-hibernation-remove +++ b/bin/omarchy-hibernation-remove @@ -4,6 +4,7 @@ # omarchy:requires-sudo=true MKINITCPIO_CONF="/etc/mkinitcpio.conf.d/omarchy_resume.conf" +RESUME_DROP_IN="/etc/limine-entry-tool.d/resume.conf" # Check if hibernation is configured if [[ ! -f $MKINITCPIO_CONF ]] || ! grep -q "^HOOKS+=(resume)$" "$MKINITCPIO_CONF"; then @@ -48,6 +49,13 @@ fi echo "Removing resume hook" sudo rm "$MKINITCPIO_CONF" +# Remove the resume kernel parameters. Setup only writes them when the file is +# missing, so a leftover would pin a later setup to this swapfile's old offset. +if [[ -f $RESUME_DROP_IN ]]; then + echo "Removing resume kernel parameters" + sudo rm "$RESUME_DROP_IN" +fi + echo "Regenerating initramfs..." sudo limine-mkinitcpio diff --git a/test/shell.d/hibernation-remove-test.sh b/test/shell.d/hibernation-remove-test.sh new file mode 100755 index 00000000000..f361887e9af --- /dev/null +++ b/test/shell.d/hibernation-remove-test.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +mkdir -p "$tmp/bin" "$tmp/etc/mkinitcpio.conf.d" "$tmp/etc/limine-entry-tool.d" "$tmp/swap" + +# Run the real script against a sandboxed /etc and /swap, with the privileged +# and interactive tools stubbed out. +sed -e "s|/etc/|$tmp/etc/|g" -e "s|\"/swap\"|\"$tmp/swap\"|" "$ROOT/bin/omarchy-hibernation-remove" >"$tmp/remove" +printf '#!/bin/bash\n"$@"\n' >"$tmp/bin/sudo" +printf '#!/bin/bash\nexit 0\n' >"$tmp/bin/gum" +printf '#!/bin/bash\nexit 0\n' >"$tmp/bin/swapon" +printf '#!/bin/bash\nexit 1\n' >"$tmp/bin/btrfs" +printf '#!/bin/bash\ntouch "%s/regenerated"\n' "$tmp" >"$tmp/bin/limine-mkinitcpio" +chmod +x "$tmp/bin/"* + +echo 'HOOKS+=(resume)' >"$tmp/etc/mkinitcpio.conf.d/omarchy_resume.conf" +echo 'KERNEL_CMDLINE[default]+=" resume=/dev/mapper/root resume_offset=1929151"' >"$tmp/etc/limine-entry-tool.d/resume.conf" +touch "$tmp/swap/swapfile" "$tmp/etc/fstab" + +PATH="$tmp/bin:$PATH" bash "$tmp/remove" >/dev/null + +[[ ! -e $tmp/etc/mkinitcpio.conf.d/omarchy_resume.conf ]] || fail "hibernation remove drops the resume hook" +# Setup only writes resume.conf when it is missing, so a leftover would pin a +# later setup to the deleted swapfile's offset. +[[ ! -e $tmp/etc/limine-entry-tool.d/resume.conf ]] || fail "hibernation remove drops the resume kernel parameters" +[[ -e $tmp/regenerated ]] || fail "hibernation remove regenerates the boot image after dropping them" +pass "hibernation remove drops the resume hook and kernel parameters"