From d4403051cfeb8e13ade466ed5c789993d592eb50 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Sat, 23 Aug 2025 16:52:25 +0200 Subject: [PATCH] Add Limine + Snapper support (#998) * Persist urgent notifications * Create omarchy-snapshot * Create snapshot before pulling * Extract alternative bootloader configs * Add limine-snapper config * Fix check * Update login scripts * Make chroot friendly * Extract cmdline instead of using blkid due to error * Add restore command * Export $TERMINAL so we get clickable restore notifications * Remove sync -- causes errors...we have nothing to sync yet * Executable * Minor cleanup and compatibility for non-ISO * Give login its own section * Give no-arg guard and inline commands --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-snapshot | 22 ++++ bin/omarchy-update | 1 + config/uwsm/env | 1 + install.sh | 6 +- install/login/bootloaders.sh | 115 ++++++++++++++++++ install/login/limine-snapper.sh | 80 ++++++++++++ .../{config/login.sh => login/plymouth.sh} | 113 ----------------- themes/catppuccin-latte/mako.ini | 3 + themes/catppuccin/mako.ini | 3 + themes/everforest/mako.ini | 3 + themes/gruvbox/mako.ini | 3 + themes/kanagawa/mako.ini | 3 + themes/matte-black/mako.ini | 3 + themes/nord/mako.ini | 3 + themes/osaka-jade/mako.ini | 3 + themes/ristretto/mako.ini | 3 + themes/rose-pine/mako.ini | 3 + themes/tokyo-night/mako.ini | 3 + 18 files changed, 257 insertions(+), 114 deletions(-) create mode 100755 bin/omarchy-snapshot create mode 100644 install/login/bootloaders.sh create mode 100644 install/login/limine-snapper.sh rename install/{config/login.sh => login/plymouth.sh} (53%) diff --git a/bin/omarchy-snapshot b/bin/omarchy-snapshot new file mode 100755 index 00000000..5e743b42 --- /dev/null +++ b/bin/omarchy-snapshot @@ -0,0 +1,22 @@ +#!/bin/bash + +COMMAND="$1" +OMARCHY_PATH=${OMARCHY_PATH:-$HOME/.local/share/omarchy} + +if [[ -z $COMMAND ]]; then + echo "Usage: omarchy-snapshot " >&2 + exit 1 +fi + +case "$COMMAND" in +create) + DESC="$(omarchy-version)" + + for config in root home; do + sudo snapper -c "$config" create -c number -d "$DESC" + done + ;; +restore) + sudo limine-snapper-restore + ;; +esac diff --git a/bin/omarchy-update b/bin/omarchy-update index 66821d1b..52b5c47f 100755 --- a/bin/omarchy-update +++ b/bin/omarchy-update @@ -2,6 +2,7 @@ set -e +omarchy-snapshot create omarchy-update-git omarchy-migrate omarchy-update-system-pkgs diff --git a/config/uwsm/env b/config/uwsm/env index b86c38b8..fa70e538 100644 --- a/config/uwsm/env +++ b/config/uwsm/env @@ -1,5 +1,6 @@ export OMARCHY_PATH=$HOME/.local/share/omarchy export PATH=$OMARCHY_PATH/bin/:$PATH +export TERMINAL=alacritty if command -v mise &> /dev/null; then eval "$(mise activate bash)" diff --git a/install.sh b/install.sh index 2bf5cfad..70753ae4 100755 --- a/install.sh +++ b/install.sh @@ -73,11 +73,15 @@ source $OMARCHY_INSTALL/config/network.sh source $OMARCHY_INSTALL/config/power.sh source $OMARCHY_INSTALL/config/usb-autosuspend.sh source $OMARCHY_INSTALL/config/timezones.sh -source $OMARCHY_INSTALL/config/login.sh source $OMARCHY_INSTALL/config/nvidia.sh source $OMARCHY_INSTALL/config/increase-sudo-tries.sh source $OMARCHY_INSTALL/config/ignore-power-button.sh +# Login +source $OMARCHY_INSTALL/login/plymouth.sh +source $OMARCHY_INSTALL/login/limine-snapper.sh +source $OMARCHY_INSTALL/login/alt-bootloaders.sh + # Development source $OMARCHY_INSTALL/development/terminal.sh source $OMARCHY_INSTALL/development/development.sh diff --git a/install/login/bootloaders.sh b/install/login/bootloaders.sh new file mode 100644 index 00000000..bb35d9b0 --- /dev/null +++ b/install/login/bootloaders.sh @@ -0,0 +1,115 @@ +if ! command -v limine &>/dev/null; then + # Add kernel hooks + if ! grep -Eq '^HOOKS=.*plymouth' /etc/mkinitcpio.conf; then + # Backup original mkinitcpio.conf just in case + backup_timestamp=$(date +"%Y%m%d%H%M%S") + sudo cp /etc/mkinitcpio.conf "/etc/mkinitcpio.conf.bak.${backup_timestamp}" + + # Add plymouth to HOOKS array after 'base udev' or 'base systemd' + if grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base systemd"; then + sudo sed -i '/^HOOKS=/s/base systemd/base systemd plymouth/' /etc/mkinitcpio.conf + elif grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base udev"; then + sudo sed -i '/^HOOKS=/s/base udev/base udev plymouth/' /etc/mkinitcpio.conf + else + echo "Couldn't add the Plymouth hook" + fi + + # Regenerate initramfs + sudo mkinitcpio -P + fi + + # Add kernel parameters for Plymouth + if [ -d "/boot/loader/entries" ]; then # systemd-boot + echo "Detected systemd-boot" + + for entry in /boot/loader/entries/*.conf; do + if [ -f "$entry" ]; then + # Skip fallback entries + if [[ "$(basename "$entry")" == *"fallback"* ]]; then + echo "Skipped: $(basename "$entry") (fallback entry)" + continue + fi + + # Skip if splash it already present for some reason + if ! grep -q "splash" "$entry"; then + sudo sed -i '/^options/ s/$/ splash quiet/' "$entry" + else + echo "Skipped: $(basename "$entry") (splash already present)" + fi + fi + done + elif [ -f "/etc/default/grub" ]; then # Grub + echo "Detected grub" + + # Backup GRUB config before modifying + backup_timestamp=$(date +"%Y%m%d%H%M%S") + sudo cp /etc/default/grub "/etc/default/grub.bak.${backup_timestamp}" + + # Check if splash is already in GRUB_CMDLINE_LINUX_DEFAULT + if ! grep -q "GRUB_CMDLINE_LINUX_DEFAULT.*splash" /etc/default/grub; then + # Get current GRUB_CMDLINE_LINUX_DEFAULT value + current_cmdline=$(grep "^GRUB_CMDLINE_LINUX_DEFAULT=" /etc/default/grub | cut -d'"' -f2) + + # Add splash and quiet if not present + new_cmdline="$current_cmdline" + if [[ ! "$current_cmdline" =~ splash ]]; then + new_cmdline="$new_cmdline splash" + fi + if [[ ! "$current_cmdline" =~ quiet ]]; then + new_cmdline="$new_cmdline quiet" + fi + + # Trim any leading/trailing spaces + new_cmdline=$(echo "$new_cmdline" | xargs) + + sudo sed -i "s/^GRUB_CMDLINE_LINUX_DEFAULT=\".*\"/GRUB_CMDLINE_LINUX_DEFAULT=\"$new_cmdline\"/" /etc/default/grub + + # Regenerate grub config + sudo grub-mkconfig -o /boot/grub/grub.cfg + else + echo "GRUB already configured with splash kernel parameters" + fi + elif [ -d "/etc/cmdline.d" ]; then # UKI + echo "Detected a UKI setup" + # Relying on mkinitcpio to assemble a UKI + # https://wiki.archlinux.org/title/Unified_kernel_image + if ! grep -q splash /etc/cmdline.d/*.conf; then + # Need splash, create the omarchy file + echo "splash" | sudo tee -a /etc/cmdline.d/omarchy.conf + fi + if ! grep -q quiet /etc/cmdline.d/*.conf; then + # Need quiet, create or append the omarchy file + echo "quiet" | sudo tee -a /etc/cmdline.d/omarchy.conf + fi + elif [ -f "/etc/kernel/cmdline" ]; then # UKI Alternate + # Alternate UKI kernel cmdline location + echo "Detected a UKI setup" + + # Backup kernel cmdline config before modifying + backup_timestamp=$(date +"%Y%m%d%H%M%S") + sudo cp /etc/kernel/cmdline "/etc/kernel/cmdline.bak.${backup_timestamp}" + + current_cmdline=$(cat /etc/kernel/cmdline) + + # Add splash and quiet if not present + new_cmdline="$current_cmdline" + if [[ ! "$current_cmdline" =~ splash ]]; then + new_cmdline="$new_cmdline splash" + fi + if [[ ! "$current_cmdline" =~ quiet ]]; then + new_cmdline="$new_cmdline quiet" + fi + + # Trim any leading/trailing spaces + new_cmdline=$(echo "$new_cmdline" | xargs) + + # Write new file + echo $new_cmdline | sudo tee /etc/kernel/cmdline + else + echo "" + echo " None of systemd-boot, GRUB, or UKI detected. Please manually add these kernel parameters:" + echo " - splash (to see the graphical splash screen)" + echo " - quiet (for silent boot)" + echo "" + fi +fi diff --git a/install/login/limine-snapper.sh b/install/login/limine-snapper.sh new file mode 100644 index 00000000..f46b214b --- /dev/null +++ b/install/login/limine-snapper.sh @@ -0,0 +1,80 @@ +if command -v limine &>/dev/null && [ ! -f /etc/default/limine ]; then + yay -S --noconfirm --needed limine-mkinitcpio-hook limine-snapper-sync + + sudo tee /etc/mkinitcpio.conf.d/omarchy_hooks.conf </dev/null +HOOKS=(base udev plymouth keyboard autodetect microcode modconf kms keymap consolefont block encrypt filesystems fsck btrfs-overlayfs) +EOF + + CMDLINE=$(grep "^[[:space:]]*cmdline:" /boot/EFI/limine/limine.conf | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//') + + sudo tee /etc/default/limine </dev/null +TARGET_OS_NAME="Omarchy" + +KERNEL_CMDLINE[default]="$CMDLINE" +KERNEL_CMDLINE[default]+="quiet splash" + +ENABLE_UKI=yes + +ENABLE_LIMINE_FALLBACK=yes + +# Find and add other bootloaders +FIND_BOOTLOADERS=yes + +BOOT_ORDER="*, *fallback, Snapshots" + +MAX_SNAPSHOT_ENTRIES=5 + +SNAPSHOT_FORMAT_CHOICE=5 +EOF + + # We overwrite the whole thing knowing the limine-update will add the entries for us + sudo tee /boot/limine.conf </dev/null +### Read more at config document: https://github.com/limine-bootloader/limine/blob/trunk/CONFIG.md +#timeout: 3 +default_entry: 2 +interface_branding: Omarchy Bootloader +interface_branding_color: 2 +hash_mismatch_panic: no + +term_background: 1a1b26 +backdrop: 1a1b26 + +# Terminal colors (Tokyo Night palette) +term_palette: 15161e;f7768e;9ece6a;e0af68;7aa2f7;bb9af7;7dcfff;a9b1d6 +term_palette_bright: 414868;f7768e;9ece6a;e0af68;7aa2f7;bb9af7;7dcfff;c0caf5 + +# Text colors +term_foreground: c0caf5 +term_foreground_bright: c0caf5 +term_background_bright: 24283b + +EOF + + # Match Snapper configs if not installing from the ISO + if [ -z "${OMARCHY_CHROOT_INSTALL:-}" ]; then + if ! sudo snapper list-configs 2>/dev/null | grep -q "root"; then + sudo snapper -c root create-config / + fi + if ! sudo snapper list-configs 2>/dev/null | grep -q "home"; then + sudo snapper -c home create-config /home + fi + end + + # Tweak default Snapper configs + sudo sed -i 's/^TIMELINE_CREATE="yes"/TIMELINE_CREATE="no"/' /etc/snapper/configs/{root,home} + sudo sed -i 's/^NUMBER_LIMIT="50"/NUMBER_LIMIT="5"/' /etc/snapper/configs/{root,home} + sudo sed -i 's/^NUMBER_LIMIT_IMPORTANT="10"/NUMBER_LIMIT_IMPORTANT="5"/' /etc/snapper/configs/{root,home} + + sudo limine-update + chrootable_systemctl_enable limine-snapper-sync.service +fi + +# Add UKI entry to UEFI machines to skip bootloader showing on normal boot +# Only doing this for ISO installs +if [ -n "${OMARCHY_CHROOT_INSTALL:-}" ] && efibootmgr &>/dev/null && ! efibootmgr | grep -q Omarchy; then + sudo efibootmgr --create \ + --disk "$(findmnt -n -o SOURCE /boot | sed 's/[0-9]*$//')" \ + --part "$(findmnt -n -o SOURCE /boot | grep -o '[0-9]*$')" \ + --label "Omarchy" \ + --loader "\\EFI\\Linux\\$(cat /etc/machine-id)_linux.efi" +fi diff --git a/install/config/login.sh b/install/login/plymouth.sh similarity index 53% rename from install/config/login.sh rename to install/login/plymouth.sh index 2b049e37..20b46dd2 100644 --- a/install/config/login.sh +++ b/install/login/plymouth.sh @@ -9,119 +9,6 @@ fi # PLYMOUTH SETUP # ============================================================================== -if ! grep -Eq '^HOOKS=.*plymouth' /etc/mkinitcpio.conf; then - # Backup original mkinitcpio.conf just in case - backup_timestamp=$(date +"%Y%m%d%H%M%S") - sudo cp /etc/mkinitcpio.conf "/etc/mkinitcpio.conf.bak.${backup_timestamp}" - - # Add plymouth to HOOKS array after 'base udev' or 'base systemd' - if grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base systemd"; then - sudo sed -i '/^HOOKS=/s/base systemd/base systemd plymouth/' /etc/mkinitcpio.conf - elif grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base udev"; then - sudo sed -i '/^HOOKS=/s/base udev/base udev plymouth/' /etc/mkinitcpio.conf - else - echo "Couldn't add the Plymouth hook" - fi - - # Regenerate initramfs - sudo mkinitcpio -P -fi - -# Add kernel parameters for Plymouth -if [ -d "/boot/loader/entries" ]; then # systemd-boot - echo "Detected systemd-boot" - - for entry in /boot/loader/entries/*.conf; do - if [ -f "$entry" ]; then - # Skip fallback entries - if [[ "$(basename "$entry")" == *"fallback"* ]]; then - echo "Skipped: $(basename "$entry") (fallback entry)" - continue - fi - - # Skip if splash it already present for some reason - if ! grep -q "splash" "$entry"; then - sudo sed -i '/^options/ s/$/ splash quiet/' "$entry" - else - echo "Skipped: $(basename "$entry") (splash already present)" - fi - fi - done -elif [ -f "/etc/default/grub" ]; then # Grub - echo "Detected grub" - - # Backup GRUB config before modifying - backup_timestamp=$(date +"%Y%m%d%H%M%S") - sudo cp /etc/default/grub "/etc/default/grub.bak.${backup_timestamp}" - - # Check if splash is already in GRUB_CMDLINE_LINUX_DEFAULT - if ! grep -q "GRUB_CMDLINE_LINUX_DEFAULT.*splash" /etc/default/grub; then - # Get current GRUB_CMDLINE_LINUX_DEFAULT value - current_cmdline=$(grep "^GRUB_CMDLINE_LINUX_DEFAULT=" /etc/default/grub | cut -d'"' -f2) - - # Add splash and quiet if not present - new_cmdline="$current_cmdline" - if [[ ! "$current_cmdline" =~ splash ]]; then - new_cmdline="$new_cmdline splash" - fi - if [[ ! "$current_cmdline" =~ quiet ]]; then - new_cmdline="$new_cmdline quiet" - fi - - # Trim any leading/trailing spaces - new_cmdline=$(echo "$new_cmdline" | xargs) - - sudo sed -i "s/^GRUB_CMDLINE_LINUX_DEFAULT=\".*\"/GRUB_CMDLINE_LINUX_DEFAULT=\"$new_cmdline\"/" /etc/default/grub - - # Regenerate grub config - sudo grub-mkconfig -o /boot/grub/grub.cfg - else - echo "GRUB already configured with splash kernel parameters" - fi -elif [ -d "/etc/cmdline.d" ]; then # UKI - echo "Detected a UKI setup" - # Relying on mkinitcpio to assemble a UKI - # https://wiki.archlinux.org/title/Unified_kernel_image - if ! grep -q splash /etc/cmdline.d/*.conf; then - # Need splash, create the omarchy file - echo "splash" | sudo tee -a /etc/cmdline.d/omarchy.conf - fi - if ! grep -q quiet /etc/cmdline.d/*.conf; then - # Need quiet, create or append the omarchy file - echo "quiet" | sudo tee -a /etc/cmdline.d/omarchy.conf - fi -elif [ -f "/etc/kernel/cmdline" ]; then # UKI Alternate - # Alternate UKI kernel cmdline location - echo "Detected a UKI setup" - - # Backup kernel cmdline config before modifying - backup_timestamp=$(date +"%Y%m%d%H%M%S") - sudo cp /etc/kernel/cmdline "/etc/kernel/cmdline.bak.${backup_timestamp}" - - current_cmdline=$(cat /etc/kernel/cmdline) - - # Add splash and quiet if not present - new_cmdline="$current_cmdline" - if [[ ! "$current_cmdline" =~ splash ]]; then - new_cmdline="$new_cmdline splash" - fi - if [[ ! "$current_cmdline" =~ quiet ]]; then - new_cmdline="$new_cmdline quiet" - fi - - # Trim any leading/trailing spaces - new_cmdline=$(echo "$new_cmdline" | xargs) - - # Write new file - echo $new_cmdline | sudo tee /etc/kernel/cmdline -else - echo "" - echo " None of systemd-boot, GRUB, or UKI detected. Please manually add these kernel parameters:" - echo " - splash (to see the graphical splash screen)" - echo " - quiet (for silent boot)" - echo "" -fi - if [ "$(plymouth-set-default-theme)" != "omarchy" ]; then sudo cp -r "$HOME/.local/share/omarchy/default/plymouth" /usr/share/plymouth/themes/omarchy/ sudo plymouth-set-default-theme -R omarchy diff --git a/themes/catppuccin-latte/mako.ini b/themes/catppuccin-latte/mako.ini index d19a1c3c..ce8b8f35 100644 --- a/themes/catppuccin-latte/mako.ini +++ b/themes/catppuccin-latte/mako.ini @@ -20,3 +20,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/catppuccin/mako.ini b/themes/catppuccin/mako.ini index 1b13e795..e1caf538 100644 --- a/themes/catppuccin/mako.ini +++ b/themes/catppuccin/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/everforest/mako.ini b/themes/everforest/mako.ini index 3c1cc74c..a0836101 100644 --- a/themes/everforest/mako.ini +++ b/themes/everforest/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/gruvbox/mako.ini b/themes/gruvbox/mako.ini index f0106a9b..2d70b15b 100644 --- a/themes/gruvbox/mako.ini +++ b/themes/gruvbox/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/kanagawa/mako.ini b/themes/kanagawa/mako.ini index 27495bda..d3ad11c3 100644 --- a/themes/kanagawa/mako.ini +++ b/themes/kanagawa/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/matte-black/mako.ini b/themes/matte-black/mako.ini index 723e855b..1af552ef 100644 --- a/themes/matte-black/mako.ini +++ b/themes/matte-black/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/nord/mako.ini b/themes/nord/mako.ini index 0a7dadd0..8c3c3193 100644 --- a/themes/nord/mako.ini +++ b/themes/nord/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/osaka-jade/mako.ini b/themes/osaka-jade/mako.ini index c179cd51..c45635de 100644 --- a/themes/osaka-jade/mako.ini +++ b/themes/osaka-jade/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/ristretto/mako.ini b/themes/ristretto/mako.ini index 036d9b34..7af1812b 100644 --- a/themes/ristretto/mako.ini +++ b/themes/ristretto/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/rose-pine/mako.ini b/themes/rose-pine/mako.ini index cab1a2e3..65aef345 100644 --- a/themes/rose-pine/mako.ini +++ b/themes/rose-pine/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0 diff --git a/themes/tokyo-night/mako.ini b/themes/tokyo-night/mako.ini index 51af6272..bf76a33b 100644 --- a/themes/tokyo-night/mako.ini +++ b/themes/tokyo-night/mako.ini @@ -19,3 +19,6 @@ invisible=true [mode=do-not-disturb app-name=notify-send] invisible=false + +[urgency=critical] +default-timeout=0