Setup hibernation more efficiently to prevent needless limine rebuilds
This commit is contained in:
@@ -2,13 +2,26 @@
|
|||||||
|
|
||||||
# omarchy:summary=Set up hibernation with swap and boot resume configuration
|
# omarchy:summary=Set up hibernation with swap and boot resume configuration
|
||||||
# omarchy:requires-sudo=true
|
# omarchy:requires-sudo=true
|
||||||
|
# omarchy:args=[--force] [--no-rebuild]
|
||||||
|
|
||||||
|
FORCE=false
|
||||||
|
NO_REBUILD=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--force) FORCE=true ;;
|
||||||
|
--no-rebuild) NO_REBUILD=true ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [[ ! -f /sys/power/image_size ]]; then
|
if [[ ! -f /sys/power/image_size ]]; then
|
||||||
echo -e "Hibernation is not supported on your system" >&2
|
echo -e "Hibernation is not supported on your system" >&2
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v limine-mkinitcpio &>/dev/null; then
|
# When --no-rebuild is set, the caller is responsible for the UKI rebuild
|
||||||
|
# (e.g. running before limine-mkinitcpio-hook is installed during initial
|
||||||
|
# install), so we only require limine-mkinitcpio when we'd invoke it ourselves.
|
||||||
|
if ! $NO_REBUILD && ! command -v limine-mkinitcpio &>/dev/null; then
|
||||||
echo "Skipping hibernation setup (requires Limine bootloader)"
|
echo "Skipping hibernation setup (requires Limine bootloader)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -26,15 +39,14 @@ if [[ -f $MKINITCPIO_CONF ]] && grep -q "^HOOKS+=(resume)$" "$MKINITCPIO_CONF";
|
|||||||
echo "Fixing empty resume_offset ($RESUME_OFFSET)"
|
echo "Fixing empty resume_offset ($RESUME_OFFSET)"
|
||||||
sudo sed -i "s/resume_offset=\"$/resume_offset=$RESUME_OFFSET\"/" "$RESUME_DROP_IN"
|
sudo sed -i "s/resume_offset=\"$/resume_offset=$RESUME_OFFSET\"/" "$RESUME_DROP_IN"
|
||||||
sudo sed -i "s/resume_offset=\"$/resume_offset=$RESUME_OFFSET\"/" /etc/default/limine
|
sudo sed -i "s/resume_offset=\"$/resume_offset=$RESUME_OFFSET\"/" /etc/default/limine
|
||||||
sudo limine-mkinitcpio
|
$NO_REBUILD || sudo limine-mkinitcpio
|
||||||
sudo limine-update
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Hibernation is already set up"
|
echo "Hibernation is already set up"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 != "--force" ]]; then
|
if ! $FORCE; then
|
||||||
MEM_TOTAL_HUMAN=$(free --human | awk '/Mem/ {print $2}')
|
MEM_TOTAL_HUMAN=$(free --human | awk '/Mem/ {print $2}')
|
||||||
if ! gum confirm "Use $MEM_TOTAL_HUMAN on boot drive to make hibernation available?"; then
|
if ! gum confirm "Use $MEM_TOTAL_HUMAN on boot drive to make hibernation available?"; then
|
||||||
exit 0
|
exit 0
|
||||||
@@ -105,13 +117,16 @@ if grep -q "\[s2idle\]" /sys/power/mem_sleep 2>/dev/null; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Regenerate initramfs and boot entry
|
if ! $NO_REBUILD; then
|
||||||
echo "Regenerating initramfs..."
|
# limine-mkinitcpio rebuilds initramfs/UKI for all kernels and updates the
|
||||||
sudo limine-mkinitcpio
|
# /boot/limine.conf entries via limine-entry-tool. The limine bootloader
|
||||||
sudo limine-update
|
# binary on the ESP doesn't change here, so we don't need limine-update
|
||||||
|
# (which would also re-deploy the binary and rebuild a second time).
|
||||||
|
echo "Regenerating initramfs..."
|
||||||
|
sudo limine-mkinitcpio
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
if ! $FORCE && ! $NO_REBUILD && gum confirm "Reboot to enable hibernation?"; then
|
||||||
|
|
||||||
if [[ $1 != "--force" ]] && gum confirm "Reboot to enable hibernation?"; then
|
|
||||||
omarchy-system-reboot
|
omarchy-system-reboot
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
run_logged $OMARCHY_INSTALL/login/plymouth.sh
|
run_logged $OMARCHY_INSTALL/login/plymouth.sh
|
||||||
run_logged $OMARCHY_INSTALL/login/default-keyring.sh
|
run_logged $OMARCHY_INSTALL/login/default-keyring.sh
|
||||||
run_logged $OMARCHY_INSTALL/login/sddm.sh
|
run_logged $OMARCHY_INSTALL/login/sddm.sh
|
||||||
|
run_logged $OMARCHY_INSTALL/login/hibernation.sh
|
||||||
run_logged $OMARCHY_INSTALL/login/limine-snapper.sh
|
run_logged $OMARCHY_INSTALL/login/limine-snapper.sh
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Run before limine-snapper.sh so the resume hook + cmdline drop-ins are in
|
||||||
|
# place when `pacman -S limine-mkinitcpio-hook` triggers its single full UKI
|
||||||
|
# rebuild. The --no-rebuild flag tells the script to skip its own rebuild —
|
||||||
|
# limine-snapper's pacman install will produce a UKI that already includes
|
||||||
|
# hibernation.
|
||||||
|
omarchy-hibernation-setup --force --no-rebuild
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
run_logged $OMARCHY_INSTALL/post-install/hibernation.sh
|
|
||||||
run_logged $OMARCHY_INSTALL/post-install/pacman.sh
|
run_logged $OMARCHY_INSTALL/post-install/pacman.sh
|
||||||
source $OMARCHY_INSTALL/post-install/allow-reboot.sh
|
source $OMARCHY_INSTALL/post-install/allow-reboot.sh
|
||||||
source $OMARCHY_INSTALL/post-install/finished.sh
|
source $OMARCHY_INSTALL/post-install/finished.sh
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
# Enable hibernation
|
|
||||||
omarchy-hibernation-setup --force
|
|
||||||
Reference in New Issue
Block a user