From 70c0f70940c72ec2b5597d24f7b0ac7128959e65 Mon Sep 17 00:00:00 2001 From: Adam Michaels Date: Tue, 9 Sep 2025 11:43:26 -0700 Subject: [PATCH] fix: implement proper hierarchical menu navigation (#1100) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: implement proper hierarchical menu navigation Add intelligent exit behavior that respects menu hierarchy and direct access: **Direct Access Behavior:** - When menus are accessed via command line arguments or keybindings - Pressing Escape/Cancel exits the application completely - Example: `omarchy-menu theme` → Escape → exits completely **Hierarchical Navigation:** - When navigating through menu system (Main → Style → Theme) - Pressing Escape/Cancel returns to parent menu - Examples: - Theme menu → Style menu (not main menu) - Font menu → Style menu (not main menu) - Power menu → Setup menu (not main menu) - Update Process/Config menus → Update menu (not main menu) **Implementation:** - `DIRECT_ACCESS` global variable tracks access method - `handle_exit(parent_menu)` provides consistent behavior - Applied to theme, font, power, and update submenus - Maintains backward compatibility for all existing navigation * Naming and add to system menu too * Naming --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-menu | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/omarchy-menu b/bin/omarchy-menu index 10786e4..27cad84 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -2,6 +2,21 @@ export PATH="$HOME/.local/share/omarchy/bin:$PATH" +# Set to true when going directly to a submenu, so we can exit directly +BACK_TO_EXIT=false + +back_to() { + local parent_menu="$1" + + if [[ "$DIRECT_ACCESS" == "true" ]]; then + exit 0 + elif [[ -n "$parent_menu" ]]; then + "$parent_menu" + else + show_main_menu + fi +} + menu() { local prompt="$1" local options="$2" @@ -80,7 +95,7 @@ show_style_menu() { show_theme_menu() { theme=$(menu "Theme" "$(omarchy-theme-list)" "" "$(omarchy-theme-current)") if [[ "$theme" == "CNCLD" || -z "$theme" ]]; then - show_main_menu + back_to show_style_menu else omarchy-theme-set "$theme" fi @@ -89,7 +104,7 @@ show_theme_menu() { show_font_menu() { theme=$(menu "Font" "$(omarchy-font-list)" "-w 350" "$(omarchy-font-current)") if [[ "$theme" == "CNCLD" || -z "$theme" ]]; then - show_main_menu + back_to show_style_menu else omarchy-font-set "$theme" fi @@ -165,7 +180,7 @@ show_setup_power_menu() { profile=$(menu "Power Profile" "$(omarchy-powerprofiles-list)" "" "$(powerprofilesctl get)") if [[ "$profile" == "CNCLD" || -z "$profile" ]]; then - show_main_menu + back_to show_setup_menu else powerprofilesctl set "$profile" fi @@ -388,7 +403,7 @@ show_system_menu() { *Relaunch*) uwsm stop ;; *Restart*) systemctl reboot ;; *Shutdown*) systemctl poweroff ;; - *) show_main_menu ;; + *) back_to show_main_menu ;; esac } @@ -417,6 +432,7 @@ go_to_menu() { } if [[ -n "$1" ]]; then + BACK_TO_EXIT=true go_to_menu "$1" else show_main_menu