From e540542fa78581a6cf9abecf9833916092f9de7a Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Mon, 12 Oct 2026 12:42:13 +0200 Subject: [PATCH] Keep plugin clones out of the omarchy. namespace for a user named omarchy A clone is named ., so for the user omarchy, cloning omarchy.menu produced omarchy.menu again. The shell rejects any third-party plugin in the omarchy. namespace, but the clone command still reported success: its discovery check and the enable call both matched the built-in of the same id, so it re-enabled the built-in and announced the clone. A derived id that lands in omarchy. now falls back to local., the scheme clones used before the username prefix. Fixes #12678 Co-Authored-By: Codex Medium Co-Authored-By: Claude Opus 5.5 --- bin/omarchy-plugin-clone | 8 +++++++- test/shell.d/plugin-clone-test.sh | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bin/omarchy-plugin-clone b/bin/omarchy-plugin-clone index 59ca16172ed4..66249d3fedf9 100755 --- a/bin/omarchy-plugin-clone +++ b/bin/omarchy-plugin-clone @@ -87,7 +87,9 @@ Copies a built-in plugin into ~/.config/omarchy/plugins/./ so you can edit it freely. The clone keeps all of the source plugin's files and kinds and uses "My " as its display name, then replaces the built-in with the clone. The username prefix keeps the id yours, so a shared clone does not -collide with anyone else's. --edit opens the clone in \$EDITOR afterwards. +collide with anyone else's, except that a username which would land the clone in +the reserved omarchy. namespace gets the shared local. instead. --edit opens +the clone in \$EDITOR afterwards. USAGE } @@ -129,6 +131,10 @@ source_info=$(omarchy-plugin-catalog | jq -r --arg id "$source_id" ' IFS=$'\t' read -r source_dir source_manifest source_name <<<"$source_info" new_id="${USER:-$(id -un)}.${source_id#omarchy.}" +# A user named omarchy would put the clone back in the omarchy. namespace the shell reserves for built-ins. +if [[ $new_id == omarchy.* ]]; then + new_id="local.${source_id#omarchy.}" +fi display_name="My $source_name" target_dir="$PLUGINS_DIR/$new_id" [[ ! -e $target_dir && ! -L $target_dir ]] || fail "$target_dir already exists" diff --git a/test/shell.d/plugin-clone-test.sh b/test/shell.d/plugin-clone-test.sh index 2c9c815525ec..c23ba7337144 100755 --- a/test/shell.d/plugin-clone-test.sh +++ b/test/shell.d/plugin-clone-test.sh @@ -49,7 +49,7 @@ clone_plugin() { } } }' - HOME="$TMPDIR/home" USER=tester OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \ + HOME="$TMPDIR/home" USER="${CLONE_USER:-tester}" OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \ FAKE_CALLS="$CALLS" OMARCHY_TEST_ROOT="$ROOT" \ FAKE_SHELL_CONFIG="${FAKE_CLONE_CONFIG:-$default_config}" \ omarchy-plugin-clone "$@" @@ -173,6 +173,20 @@ fi fail "rejected custom id leaves a clone behind" pass "clone derives the personal id from the username" +for user in omarchy omarchy.dev; do + : >"$CALLS" + CLONE_USER=$user clone_plugin omarchy.weather >/dev/null + [[ ! -e $TMPDIR/home/.config/omarchy/plugins/$user.weather ]] || + fail "user $user clones into the reserved omarchy namespace" + jq -e '.id == "local.weather" and .omarchy.clonedFrom == "omarchy.weather"' \ + "$TMPDIR/home/.config/omarchy/plugins/local.weather/manifest.json" >/dev/null || + fail "user $user does not get a local clone id" + grep -qx 'omarchy-plugin-enable local.weather' "$CALLS" || + fail "user $user does not get the clone enabled" + rm -rf "$TMPDIR/home/.config/omarchy/plugins/local.weather" +done +pass "a username in the omarchy namespace clones outside it" + if clone_plugin omarchy.weather --replace >/dev/null 2>&1; then fail "clone still accepts bar layout actions" fi