The omarchy-bar command had grown three overlapping ways to inspect the bar (show/layout/list/options, plus selected/active/available/widgets aliases) and mixed layout mutation in with bar-level settings. Untangle it into two focused commands: - omarchy-bar keeps only the bar-level settings that write shell.json: use, reset, position, transparent, and settings. reset now delegates to `use omarchy.bar` rather than duplicating the del(.bar.id) write. - omarchy-bar-plugin owns all layout mutation: add, move, remove, set, and replace, with the placement flags and jq resolve/anchor helpers. `omarchy bar plugin ...` routes here via the dispatcher. Drop the inspection commands entirely: the layout is visible on the bar, the config is shell.json, and widget/option ids come from `omarchy plugin list`. Nothing consumed the show output programmatically except tests. This also removes omarchy-bar-position, whose jq write was a duplicate of `omarchy bar position`. Strip environment-invariant guards (require_command, require_omarchy_path) that defended against jq or OMARCHY_PATH being absent — neither happens on a real system. Keep the user-input validation (--section/--index) and the atomic shell.json write. Update callers (service install/remove, refresh-shell, plugin-clone, plugin enable), keybindings, the menu, tests, and docs to the new split.
69 lines
2.3 KiB
Bash
Executable File
69 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Emit every first-party and user plugin manifest as JSON
|
|
# omarchy:group=plugin
|
|
# omarchy:hidden=true
|
|
|
|
# Walks $OMARCHY_PATH/shell/plugins and ~/.config/omarchy/plugins, reads every
|
|
# manifest.json / *.manifest.json, and emits one JSON object per plugin with
|
|
# computed fields (sourceDir, barWidgetPath, barPath, firstParty). This is the
|
|
# single source of truth that omarchy-bar (widget/option enumeration),
|
|
# omarchy-bar-plugin (add validation), and omarchy-plugin-clone (source
|
|
# enumeration) read, so the bar and plugin commands never re-implement
|
|
# manifest walking.
|
|
|
|
set -o pipefail
|
|
|
|
OMARCHY_PATH="${OMARCHY_PATH:-}"
|
|
command -v jq >/dev/null 2>&1 || { echo "omarchy-plugin-catalog: jq is required" >&2; exit 1; }
|
|
|
|
paths=()
|
|
|
|
if [[ -n $OMARCHY_PATH && -d $OMARCHY_PATH/shell/plugins ]]; then
|
|
while IFS= read -r manifest; do
|
|
paths+=("$manifest")
|
|
done < <(find "$OMARCHY_PATH/shell/plugins" -mindepth 2 -maxdepth 4 -type f \( -name manifest.json -o -name '*.manifest.json' \) 2>/dev/null | sort)
|
|
fi
|
|
|
|
user_dir="$HOME/.config/omarchy/plugins"
|
|
if [[ -d $user_dir ]]; then
|
|
while IFS= read -r manifest; do
|
|
paths+=("$manifest")
|
|
done < <(find -L "$user_dir" -mindepth 2 -maxdepth 2 -type f -name manifest.json 2>/dev/null | sort)
|
|
fi
|
|
|
|
if (( ${#paths[@]} == 0 )); then
|
|
echo "[]"
|
|
exit 0
|
|
fi
|
|
|
|
jq -n '
|
|
[ inputs
|
|
| . as $manifest
|
|
| input_filename as $manifestPath
|
|
| ($manifestPath | sub("/manifest.json$"; "") | sub("/[^/]+\\.manifest\\.json$"; "")) as $sourceDir
|
|
| {
|
|
id: ($manifest.id // ""),
|
|
name: ($manifest.name // $manifest.id // ""),
|
|
description: ($manifest.description // ""),
|
|
kinds: ($manifest.kinds // []),
|
|
firstParty: (($manifest.id // "") | startswith("omarchy.")),
|
|
manifestPath: $manifestPath,
|
|
sourceDir: $sourceDir,
|
|
entryPoints: ($manifest.entryPoints // {}),
|
|
barWidget: ($manifest.barWidget // null),
|
|
bar: ($manifest.bar // null)
|
|
}
|
|
| .barWidgetPath = (
|
|
if (.entryPoints.barWidget // null) != null
|
|
then (.sourceDir + "/" + .entryPoints.barWidget)
|
|
else null end)
|
|
| .barPath = (
|
|
if (.entryPoints.bar // null) != null
|
|
then (.sourceDir + "/" + .entryPoints.bar)
|
|
else null end)
|
|
| select(.id != "")
|
|
]
|
|
| unique_by(.id)
|
|
' "${paths[@]}"
|