Restore menu toggle behavior on keybinds and bar clicks

The old bash bin short-circuited with close_visible_quickshell_menu at
the top of open_quickshell_menu, so pressing any menu keybind while the
menu was open just closed it. The IPC path I introduced summoned every
time, so keyboard shortcuts couldn't dismiss \u2014 only outside clicks did
(which is why the bar icon appeared to toggle: clicking it while the
menu was open hit the menu's outer-click MouseArea, not the icon).

Add a menu.toggle IPC method:
  - if root.opened: cancel() and return "closed"
  - otherwise: behaves exactly like summon

Switch every Hyprland binding and the two bar-icon click handlers
(omarchy logo, battery right-click \u2192 power menu) to toggle. summon stays
as the always-open primitive for callers that want explicit summon
semantics (rare \u2014 right now nothing internal uses it).
This commit is contained in:
Ryan Hughes
2026-05-14 18:04:25 -04:00
parent edfd68d48e
commit 679e14c37f
3 changed files with 26 additions and 15 deletions
@@ -690,6 +690,17 @@ Item {
return "ok"
}
// Hitting the same menu keybind while the menu is already visible should
// close it — even if the requested target differs from the active one.
// Matches the old bash bin's `close_visible_quickshell_menu` short-circuit.
function toggle(initialMenu: string): string {
if (root.opened) {
root.cancel()
return "closed"
}
return summon(initialMenu)
}
function refresh(): string {
defaultMenuFile.reload()
userMenuFile.reload()
@@ -697,7 +708,7 @@ Item {
}
function close(): string {
root.close()
root.cancel()
return "ok"
}