From 4b7fe16029131f744e1caf5e453806ab0cbc01df Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 25 Apr 2026 21:33:46 +0200 Subject: [PATCH] Offer direct boot as a toggle option --- bin/omarchy-config-direct-boot | 45 ++++++++++++++++++++++------------ bin/omarchy-menu | 3 ++- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/bin/omarchy-config-direct-boot b/bin/omarchy-config-direct-boot index 6bb82123..50f3ba62 100755 --- a/bin/omarchy-config-direct-boot +++ b/bin/omarchy-config-direct-boot @@ -1,6 +1,6 @@ #!/bin/bash -# Add an EFI boot entry for the Omarchy UKI, allowing the system to boot directly +# Add or remove an EFI boot entry for the Omarchy UKI, allowing the system to boot directly # without a bootloader like Limine. Requires UEFI firmware and a built UKI. if [[ ! -d /sys/firmware/efi ]]; then @@ -23,23 +23,36 @@ if cat /sys/class/dmi/id/bios_vendor 2>/dev/null | grep -qi "Apple"; then exit 1 fi -uki_file=$(find /boot/EFI/Linux/ -name "omarchy*.efi" -printf "%f\n" 2>/dev/null | head -1) +existing_entry=$(efibootmgr | grep -E "^Boot[0-9A-Fa-f]+\*? Omarchy([[:space:]]|$)" | head -1) -if [[ -z $uki_file ]]; then - echo "Error: No Omarchy UKI found in /boot/EFI/Linux/" >&2 - exit 1 -fi +if [[ -n $existing_entry ]]; then + boot_num=$(echo "$existing_entry" | sed -n 's/^Boot\([0-9A-Fa-f]\+\).*/\1/p') -boot_source=$(findmnt -n -o SOURCE /boot) -disk=$(echo "$boot_source" | sed 's/p\?[0-9]*$//') -part=$(echo "$boot_source" | grep -o 'p\?[0-9]*$' | sed 's/^p//') + if gum confirm "Disable direct boot (remove Omarchy EFI entry)?"; then + echo "Removing EFI boot entry $boot_num" + sudo efibootmgr --bootnum "$boot_num" --delete-bootnum >/dev/null + fi -if gum confirm "Setup direct boot (so snapshot booting must be done via bios)?"; then - echo "Creating EFI boot entry for $uki_file" + exit 0 +else + uki_file=$(find /boot/EFI/Linux/ -name "omarchy*.efi" -printf "%f\n" 2>/dev/null | head -1) - sudo efibootmgr --create \ - --disk "$disk" \ - --part "$part" \ - --label "Omarchy" \ - --loader "\\EFI\\Linux\\$uki_file" + if [[ -z $uki_file ]]; then + echo "Error: No Omarchy UKI found in /boot/EFI/Linux/" >&2 + exit 1 + fi + + boot_source=$(findmnt -n -o SOURCE /boot) + disk=$(echo "$boot_source" | sed 's/p\?[0-9]*$//') + part=$(echo "$boot_source" | grep -o 'p\?[0-9]*$' | sed 's/^p//') + + if gum confirm "Setup direct boot (so snapshot booting must be done via bios)?"; then + echo "Creating EFI boot entry for $uki_file" + + sudo efibootmgr --create \ + --disk "$disk" \ + --part "$part" \ + --label "Omarchy" \ + --loader "\\EFI\\Linux\\$uki_file" + fi fi diff --git a/bin/omarchy-menu b/bin/omarchy-menu index 4cd677c2..b9595f84 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -168,7 +168,7 @@ show_share_menu() { } show_toggle_menu() { - local options="󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Monitor Scaling\n" + local options="󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Monitor Scaling\n Direct Boot" case $(menu "Toggle" "$options") in *Screensaver*) omarchy-toggle-screensaver ;; @@ -179,6 +179,7 @@ show_toggle_menu() { *Ratio*) omarchy-hyprland-window-single-square-aspect-toggle ;; *Gaps*) omarchy-hyprland-window-gaps-toggle ;; *Scaling*) omarchy-hyprland-monitor-scaling-cycle ;; + *"Direct Boot"*) present_terminal omarchy-config-direct-boot ;; *) back_to show_trigger_menu ;; esac }