fix(menu): quick-state actions return to their submenu instead of exiting

After the cancel-branch sweep, the remaining UX inconsistency was in
action branches: changing one setting kicked the user out of the menu,
forcing a relaunch to change the next. Brought 16 actions across 5
submenus into the same return-to-self pattern theme/background got.

Classification rule applied:

- Quick-state actions (toggle, set, restart-service - finishes in
  milliseconds, no window opens) -> back_to <self>, so the user can
  chain "toggle nightlight, then toggle gaps, then restart waybar"
  without rerunning nomarchy-menu each time.
- Window-opening actions (editor, floating terminal, audio/wifi/bt
  launcher, browser, hyprpicker overlay, screenshot, screenrecord,
  share dialogs, lock/shutdown/logout) stay as one-shot exits -
  re-popping the menu over the new window would be visual noise.

Submenus changed:

- show_toggle_menu (8 toggles): screensaver, nightlight, idle, top
  bar, workspace layout, window gaps, 1-window ratio, display scaling.
- show_setup_power_menu: powerprofilesctl set returns; cancel still
  goes up to show_setup_menu (different destinations on each branch,
  so the if/else stays).
- show_font_menu: nomarchy-font-set returns; cancel still goes up.
- show_setup_system_menu: the suspend toggle (quick) returns;
  hibernate enable/disable (terminal) still exit.
- show_update_process_menu (5 service restarts): hypridle, hyprsunset,
  swayosd, walker, waybar.

For dynamically-rendered menus (show_setup_system_menu rebuilds its
options each invocation based on current state) this also gives free
visual feedback - the toggle's label flips between "Enable Suspend"
and "Disable Suspend" when the menu re-renders.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-04-30 20:01:48 +01:00
parent 4b99fa3846
commit 5c5b377bd6

View File

@@ -146,14 +146,14 @@ show_share_menu() {
show_toggle_menu() { show_toggle_menu() {
case $(menu "Toggle" "󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Display Scaling") in case $(menu "Toggle" "󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Display Scaling") in
*Screensaver*) nomarchy-toggle-screensaver ;; *Screensaver*) nomarchy-toggle-screensaver; back_to show_toggle_menu ;;
*Nightlight*) nomarchy-toggle-nightlight ;; *Nightlight*) nomarchy-toggle-nightlight; back_to show_toggle_menu ;;
*Idle*) nomarchy-toggle-idle ;; *Idle*) nomarchy-toggle-idle; back_to show_toggle_menu ;;
*Bar*) nomarchy-toggle-waybar ;; *Bar*) nomarchy-toggle-waybar; back_to show_toggle_menu ;;
*Layout*) nomarchy-hyprland-workspace-layout-toggle ;; *Layout*) nomarchy-hyprland-workspace-layout-toggle; back_to show_toggle_menu ;;
*Ratio*) nomarchy-hyprland-window-single-square-aspect-toggle ;; *Ratio*) nomarchy-hyprland-window-single-square-aspect-toggle; back_to show_toggle_menu ;;
*Gaps*) nomarchy-hyprland-window-gaps-toggle ;; *Gaps*) nomarchy-hyprland-window-gaps-toggle; back_to show_toggle_menu ;;
*Scaling*) nomarchy-hyprland-monitor-scaling-cycle ;; *Scaling*) nomarchy-hyprland-monitor-scaling-cycle; back_to show_toggle_menu ;;
*) back_to show_trigger_menu ;; *) back_to show_trigger_menu ;;
esac esac
} }
@@ -193,6 +193,7 @@ show_font_menu() {
back_to show_style_menu back_to show_style_menu
else else
nomarchy-font-set "$theme" nomarchy-font-set "$theme"
back_to show_font_menu
fi fi
} }
@@ -225,6 +226,7 @@ show_setup_power_menu() {
back_to show_setup_menu back_to show_setup_menu
else else
powerprofilesctl set "$profile" powerprofilesctl set "$profile"
back_to show_setup_power_menu
fi fi
} }
@@ -268,7 +270,7 @@ show_setup_system_menu() {
fi fi
case $(menu "System" "$options") in case $(menu "System" "$options") in
*Suspend*) nomarchy-toggle-suspend ;; *Suspend*) nomarchy-toggle-suspend; back_to show_setup_system_menu ;;
*"Enable Hibernate"*) present_terminal nomarchy-hibernation-setup ;; *"Enable Hibernate"*) present_terminal nomarchy-hibernation-setup ;;
*"Disable Hibernate"*) present_terminal nomarchy-hibernation-remove ;; *"Disable Hibernate"*) present_terminal nomarchy-hibernation-remove ;;
*) back_to show_setup_menu ;; *) back_to show_setup_menu ;;
@@ -292,11 +294,11 @@ show_update_menu() {
} }
show_update_process_menu() { show_update_process_menu() {
case $(menu "Restart" " Hypridle\n Hyprsunset\n Swayosd\n󰌧 Walker\n󰍜 Waybar") in case $(menu "Restart" " Hypridle\n Hyprsunset\n Swayosd\n󰌧 Walker\n󰍜 Waybar") in
*Hypridle*) nomarchy-restart-hypridle ;; *Hypridle*) nomarchy-restart-hypridle; back_to show_update_process_menu ;;
*Hyprsunset*) nomarchy-restart-hyprsunset ;; *Hyprsunset*) nomarchy-restart-hyprsunset; back_to show_update_process_menu ;;
*Swayosd*) nomarchy-restart-swayosd ;; *Swayosd*) nomarchy-restart-swayosd; back_to show_update_process_menu ;;
*Walker*) nomarchy-restart-walker ;; *Walker*) nomarchy-restart-walker; back_to show_update_process_menu ;;
*Waybar*) nomarchy-restart-waybar ;; *Waybar*) nomarchy-restart-waybar; back_to show_update_process_menu ;;
*) back_to show_update_menu ;; *) back_to show_update_menu ;;
esac esac
} }