Add omarchy-menu wrapper for ergonomic CLI use

`omarchy-shell-ipc menu toggle root` is what the keybinds use \u2014 it
skips the omarchy CLI dispatch hop and stays sub-ms. But humans don't
want to type that. New tiny wrapper restores `omarchy menu …` as the
CLI entry point:

  omarchy menu                  → toggle root (bare invocation)
  omarchy menu toggle [route]   → toggle, route defaults to root
  omarchy menu summon [route]   → always open
  omarchy menu close            → close if open
  omarchy menu refresh          → re-parse the menu JSONCs
  omarchy menu ping             → health check

Internally each verb just execs `omarchy-shell-ipc menu …`. The
omarchy-CLI dispatcher overhead measures ~2ms on top of the direct IPC
path (32ms → 34ms keybind-to-visible), so the wrapper is fine for any
human-typed invocation; keybinds and the bar icon stay on
omarchy-shell-ipc to keep that ~30ms hot path.

Sibling `omarchy menu file`, `omarchy menu input`, etc. still resolve
through their own bins \u2014 the dispatcher picks the longest matching
prefix, so longer routes ("omarchy menu file") win over the bare
"omarchy menu" entry.
This commit is contained in:
Ryan Hughes
2026-05-14 18:26:50 -04:00
parent 679e14c37f
commit 765b068e86
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
# omarchy:summary=Control the Omarchy menu (toggle / summon / close / refresh)
# omarchy:args=[toggle|summon|close|refresh|ping] [route]
# omarchy:examples=omarchy menu | omarchy menu toggle system | omarchy menu summon style.theme | omarchy menu refresh
# Thin wrapper around `omarchy-shell-ipc menu`. Keybinds and the bar icon
# call omarchy-shell-ipc directly to skip the omarchy-CLI dispatch hop;
# this exists so humans get `omarchy menu toggle X` etc.
verb="${1-toggle}"
route="${2-root}"
case "$verb" in
toggle | summon)
exec omarchy-shell-ipc menu "$verb" "$route"
;;
close | refresh | ping)
exec omarchy-shell-ipc menu "$verb"
;;
-h | --help | help)
cat <<USAGE
Usage: omarchy menu [verb] [route]
Verbs:
toggle [route] Open the menu at <route>, or close it if already open. Default verb.
summon [route] Always open the menu (no close-if-visible toggle).
close Close the menu if it is visible.
refresh Re-parse the menu JSONC files.
ping Health check.
Route is an item id (e.g. setup.power) or alias (e.g. power). Defaults to
"root", which opens the top-level menu.
USAGE
exit 0
;;
*)
echo "omarchy-menu: unknown verb '$verb'. Try 'omarchy menu --help'." >&2
exit 2
;;
esac