Files
arthur-os/bin/omarchy-plugin-scan
T
Ryan Hughes 1bb439476a Add third-party plugin sources and installer
Let users add trusted plugin source repos and add/update/remove plugins
from them, alongside the existing in-shell plugin commands:

  omarchy plugin source <add|list|remove|refresh>
  omarchy plugin available
  omarchy plugin add | update | remove | validate

Each command is interactive (gum/fzf pickers, confirmation, an update
diff) in a TTY and fully flag-driven with --yes for scripts and agents.
Sources live in ~/.config/omarchy/plugins/sources.json and clone into
~/.cache/omarchy/plugin-sources/. The installer only copies files,
validates manifests against the shell's schema, and toggles enabled
state over IPC -- it never runs plugin code, hooks, or sudo.

Also guard 'plugin bar add' so only known bar-widget ids enter the
layout (rejecting typos/non-widgets like a stray '--help').
2026-05-29 16:55:15 -04:00

61 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# omarchy:summary=List every plugin available across configured sources (JSON)
# omarchy:group=plugin
# omarchy:hidden=true
# Walks the locally cached clones of every trusted source and emits one JSON
# entry per plugin folder it finds. This is the shared catalogue that
# `available`, `install`, and `update` all read; it never touches the network
# (run `omarchy plugin source refresh` first to pull fresh clones).
set -o pipefail
SOURCES_FILE="$HOME/.config/omarchy/plugins/sources.json"
CACHE_ROOT="$HOME/.cache/omarchy/plugin-sources"
command -v jq >/dev/null 2>&1 || { echo "omarchy-plugin-scan: jq is required" >&2; exit 1; }
if [[ ! -f $SOURCES_FILE ]]; then
echo "[]"
exit 0
fi
results='[]'
# Read each source as a compact JSON object (one per line) rather than a
# delimiter-joined string — no separator to get wrong, and empty fields survive.
while IFS= read -r src_json; do
[[ -n $src_json ]] || continue
src_id=$(jq -r '.id // ""' <<<"$src_json")
src_url=$(jq -r '.url // ""' <<<"$src_json")
src_ref=$(jq -r '.ref // ""' <<<"$src_json")
[[ -n $src_id ]] || continue
cache_dir="$CACHE_ROOT/$src_id"
[[ -d $cache_dir ]] || continue
for folder in "$cache_dir"/*/; do
[[ -d $folder ]] || continue
manifest="$folder/manifest.json"
[[ -f $manifest ]] || continue
jq -e . "$manifest" >/dev/null 2>&1 || continue
folder_name=$(basename "$folder")
abs_path=$(cd "$folder" && pwd)
entry=$(jq -n \
--arg sourceId "$src_id" \
--arg sourceUrl "$src_url" \
--arg ref "$src_ref" \
--arg folder "$folder_name" \
--arg path "$abs_path" \
--slurpfile manifest "$manifest" \
'{sourceId:$sourceId, sourceUrl:$sourceUrl, ref:$ref, folder:$folder, path:$path, manifest:$manifest[0]}') || continue
results=$(jq --argjson e "$entry" '. + [$e]' <<<"$results")
done
done < <(jq -c '.sources[]?' "$SOURCES_FILE")
echo "$results"