Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bin/omarchy-plugin-hold
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# omarchy:summary=Keep a plugin out of updates that do not name it
# omarchy:group=plugin
# omarchy:args=<id>

set -euo pipefail

fail() {
echo "omarchy-plugin-hold: $*" >&2
exit 1
}

if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then
echo "Usage: omarchy plugin hold <id>"
exit 0
fi

id="${1:-}"
[[ -n $id ]] || fail "plugin id is required"
[[ $id =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ && $id != *..* ]] || fail "invalid plugin id '$id'"

held_dir="$HOME/.local/state/omarchy/plugins/held"
mkdir -p "$held_dir" && : >"$held_dir/$id"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed holds report success

If mkdir -p fails, Bash skips the file write but continues to the success message because the failed command is on the left of &&. The command then exits successfully without saving the hold, so later bulk updates can still change the plugin. Run directory creation and the file write as separate commands, or explicitly fail when either fails.

Suggested change
mkdir -p "$held_dir" && : >"$held_dir/$id"
mkdir -p "$held_dir"
: >"$held_dir/$id"


echo "Held $id: plugin updates skip it until: omarchy plugin unhold $id"
26 changes: 26 additions & 0 deletions bin/omarchy-plugin-unhold
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# omarchy:summary=Let a held plugin update again
# omarchy:group=plugin
# omarchy:args=<id>

set -euo pipefail

fail() {
echo "omarchy-plugin-unhold: $*" >&2
exit 1
}

if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then
echo "Usage: omarchy plugin unhold <id>"
exit 0
fi

id="${1:-}"
[[ -n $id ]] || fail "plugin id is required"
[[ $id =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ && $id != *..* ]] || fail "invalid plugin id '$id'"

held_dir="$HOME/.local/state/omarchy/plugins/held"
rm -f "$held_dir/$id"

echo "Unheld $id"
9 changes: 8 additions & 1 deletion bin/omarchy-plugin-update
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export GIT_TERMINAL_PROMPT=0
export GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-ssh -oBatchMode=yes}"

PLUGINS_DIR="$HOME/.config/omarchy/plugins"
# Plugins held with omarchy plugin hold, skipped unless named.
HELD_DIR="$HOME/.local/state/omarchy/plugins/held"
ASSUME_YES=0
UPDATED_ANY=0

Expand Down Expand Up @@ -114,7 +116,12 @@ if [[ -n $id ]]; then
else
for dir in "$PLUGINS_DIR"/*/; do
[[ -d $dir/.git ]] || continue
targets+=("$(basename "$dir")")
plugin=$(basename "$dir")
if [[ -f $HELD_DIR/$plugin ]]; then
Comment on lines +119 to +120

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Held plugins can still update

The hold check uses the folder name instead of the manifest's id. A manually installed git plugin can live in different-folder while the shell lists it as acme.same; existing tests cover this layout. Running omarchy plugin hold acme.same reports success, but bulk updates still fetch and update that plugin. An unattended update can therefore replace code the user asked to keep unchanged. Read the manifest's id when checking whether a plugin is held.

echo "$plugin is held back; run: omarchy plugin unhold $plugin"
continue
fi
targets+=("$plugin")
done
if (( ${#targets[@]} == 0 )); then
echo "No git-managed plugins installed."
Expand Down
13 changes: 13 additions & 0 deletions bin/omarchy-update
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then
omarchy-done mark first-update
omarchy-shell -q omarchy.system-update clear

# Plugins are third-party code, so updating them here is opt-in
# (omarchy-toggle update-plugins). The shell restart below loads what changed.
if omarchy-toggle-enabled update-plugins; then
if [[ ${OMARCHY_UPDATE_UNATTENDED:-} == "1" ]]; then
plugin_update_args=(--yes)
else
plugin_update_args=()
fi
if ! omarchy-plugin-update "${plugin_update_args[@]}"; then
echo -e "\e[33m\nSome plugins could not be updated. Review the errors above and run 'omarchy plugin update' to retry.\e[0m" >&2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Plugin warning stays English

The new plugin failure warning prints English directly. The repository requires warnings from omarchy update to use omarchy-i18n, so users receive them in their chosen language. Add an English catalog entry and print it through that helper. This repository requirement must be satisfied before merging.

File Used: docs/i18n.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

fi
fi

# Service restart helpers can need sudo. The reboot-only phase below
# performs no privileged work.
omarchy-update-restart --services-only
Expand Down
2 changes: 2 additions & 0 deletions docs/update-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ omarchy-update
├─ run migrations
├─ automatically remove orphan packages and run log analysis
├─ clear the shell update indicator: the update just installed what it showed
├─ update git-managed plugins, only when the update-plugins toggle is on (held plugins are skipped)
│ (-y approves each change, a failed plugin warns and the update continues)
├─ restart marked services and the shell
├─ run the post-update hook, then update mise tools (a failed tool update
│ warns and the update continues)
Expand Down
10 changes: 10 additions & 0 deletions manual/30-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ Finally, there's the dev channel, which links Omarchy directly to a git checkout

You can switch between channels using _Update > Channel_ from the Omarchy menu (or `omarchy channel set <stable|rc|edge|dev>` in the terminal, with `omarchy channel current` to see where you are).

### Updating plugins with Omarchy

Shell plugins you added with `omarchy plugin add` are not part of an update by default. They are third-party code that runs inside your shell, so Omarchy leaves them to you and `omarchy plugin update`. If you'd rather keep them current with everything else, turn it on once:

```
omarchy-toggle update-plugins on
```

From then on, `omarchy update` also runs `omarchy plugin update` near the end, before it restarts the shell, so the new plugin code is what comes back up. You still see each plugin's diff and confirm it, unless you run `omarchy update -y`, which approves them. A plugin that fails to update prints a warning, and the rest of the update finishes. Turn it off again with `omarchy-toggle update-plugins off`. To keep a single plugin out of it, use `omarchy plugin hold <id>` (see the shell plugins chapter).

### Switching kernels

Omarchy boots its own `linux-omarchy` kernel, but you can keep others installed next to it, like the stock Arch `linux` kernel or an experimental build you're testing. When there's more than one, _Update > Kernel_ in the Omarchy menu lists them with a check next to the one that boots by default. Pick another, enter your password once, and it'll boot after the next restart. The other kernels stay in the boot menu, so you can still pick one by hand if the new default gives you trouble. In the terminal, it's `omarchy kernel` to see the current default, `omarchy kernel list` for what's installed, and `omarchy kernel set <kernel>` to switch.
Expand Down
11 changes: 10 additions & 1 deletion manual/32-shell-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ omarchy plugin update acme.weather
omarchy plugin update
```

With no id it updates every git-managed plugin you have. It shows you the diff before applying it, refuses to update if you've got local changes it can't fast-forward past, and rolls back if the new revision fails validation.
With no id it updates every git-managed plugin you have. It shows you the diff before applying it, refuses to update if you've got local changes it can't fast-forward past, and rolls back if the new revision fails validation. To have `omarchy update` do this for you, see _Updating plugins with Omarchy_ in the updates chapter.

If you need one plugin to stay where it is, because you patched it locally or its latest version broke something, hold it:

```
omarchy plugin hold acme.weather
omarchy plugin unhold acme.weather
```

A held plugin is skipped by `omarchy plugin update` with no id, and so by `omarchy update` too. Naming it, as in `omarchy plugin update acme.weather`, still updates it, because you asked for that one.

```
omarchy plugin remove acme.weather
Expand Down
55 changes: 55 additions & 0 deletions test/shell.d/plugin-hold-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
mkdir -p "$TMPDIR/bin"
home="$TMPDIR/home"
calls="$TMPDIR/calls"
for id in alpha.one beta.two; do
mkdir -p "$home/.config/omarchy/plugins/$id/.git"
done

# git reports every plugin up to date and records which one it was asked about.
cat >"$TMPDIR/bin/git" <<'SH'
#!/bin/bash
[[ $1 == "-C" ]] && printf '%s %s\n' "${2##*/}" "$3" >>"$OMARCHY_TEST_CALLS"
[[ $3 == "rev-parse" ]] && echo same
exit 0
SH
chmod +x "$TMPDIR/bin/git"

run() {
HOME="$home" OMARCHY_PATH="$ROOT" OMARCHY_TEST_CALLS="$calls" \
PATH="$TMPDIR/bin:$ROOT/bin:$PATH" "$@"
}

run omarchy-plugin-hold beta.two >/dev/null
[[ -f $home/.local/state/omarchy/plugins/held/beta.two ]] || fail "hold did not record the plugin"
pass "plugin hold records the plugin"

: >"$calls"
out=$(run omarchy-plugin-update --yes)
grep -q '^alpha.one fetch' "$calls" || fail "update skipped a plugin that is not held"
! grep -q '^beta.two' "$calls" || fail "update touched a held plugin"
grep -Fq 'beta.two is held back' <<<"$out" || fail "update did not say the plugin is held"
pass "plugin update skips a held plugin and says so"

: >"$calls"
run omarchy-plugin-update beta.two --yes >/dev/null
grep -q '^beta.two fetch' "$calls" || fail "update by name did not update a held plugin"
pass "plugin update by name still updates a held plugin"

run omarchy-plugin-unhold beta.two >/dev/null
: >"$calls"
run omarchy-plugin-update --yes >/dev/null
grep -q '^beta.two fetch' "$calls" || fail "unhold did not let the plugin update again"
pass "plugin unhold lets it update again"

if run omarchy-plugin-hold '../evil' >/dev/null 2>&1; then
fail "hold accepted a path as a plugin id"
fi
pass "plugin hold rejects ids that are not plugin ids"
46 changes: 45 additions & 1 deletion test/shell.d/update-sequence-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ steps=(
omarchy-shell
omarchy-update-available
omarchy-update-restart
omarchy-toggle-enabled
omarchy-plugin-update
)

for step in "${steps[@]}"; do
Expand All @@ -56,6 +58,13 @@ fi
if [[ ${0##*/} == "omarchy-update-analyze-logs" ]]; then
printf '%s\n' "$*" >"$STEP_LOG.analyze-args"
fi
if [[ ${0##*/} == "omarchy-toggle-enabled" ]]; then
printf '%s\n' "$*" >"$STEP_LOG.toggle-args"
[[ ${PLUGIN_UPDATES:-} == 1 ]] || exit 1
fi
if [[ ${0##*/} == "omarchy-plugin-update" ]]; then
printf '%s\n' "$*" >"$STEP_LOG.plugin-args"
fi
[[ ${FAILING_STEP:-} != "${0##*/}" ]] || exit 1
STUB
chmod +x "$stub_bin/$step"
Expand All @@ -77,7 +86,8 @@ steps_run() {
}

# Every step of a whole update, in order. $1 asks for the one a person confirms;
# an empty $2 leaves out the shell restart, for an update with nothing to migrate.
# an empty $2 leaves out the shell restart, for an update with nothing to migrate;
# $3 asks for the plugin update a person opted into.
# Stay Awake bookends the work, so it is here twice.
expected_steps() {
printf '%s\n' \
Expand All @@ -97,6 +107,8 @@ expected_steps() {
omarchy-update-analyze-logs \
omarchy-done \
omarchy-shell \
omarchy-toggle-enabled \
${3:+omarchy-plugin-update} \
omarchy-update-restart \
omarchy-hook \
omarchy-update-mise \
Expand Down Expand Up @@ -229,3 +241,35 @@ HOME="$restart_home" \
grep -q "update.hyprlandReboot" "$test_tmp/restart-prompts" ||
fail "omarchy-update-restart offers a reboot when a later Hyprland PID runs a deleted binary" "$(cat "$test_tmp/restart-prompts")"
pass "omarchy-update-restart checks every Hyprland PID for a deleted executable"

# Plugins are third-party code, so the update leaves them alone unless the
# person opted in. When they did, plugins update before the shell restart so the
# restart loads the new code, and a plugin failure never fails the system update.
run_update -y || fail "an update without plugin updates reports a failure"
[[ $(cat "$test_tmp/steps.toggle-args") == "update-plugins" ]] ||
fail "the update checks the wrong toggle for plugin updates" "$(cat "$test_tmp/steps.toggle-args")"
if grep -q '^omarchy-plugin-update ' "$test_tmp/steps"; then
fail "an update updates plugins nobody opted into"
fi
pass "an update leaves plugins alone unless the person opted in"

PLUGIN_UPDATES=1 run_update -y || fail "an opted-in unattended update reports a failure"
diff <(expected_steps "" omarchy-restart-shell plugins) <(steps_run) >"$test_tmp/order" ||
fail "an opted-in update does not update plugins before the shell restart" "$(cat "$test_tmp/order")"
[[ $(cat "$test_tmp/steps.plugin-args") == "--yes" ]] ||
fail "an unattended update still asks to review plugin changes" "$(cat "$test_tmp/steps.plugin-args")"
pass "an opted-in unattended update approves plugin updates before the shell restart"

PLUGIN_UPDATES=1 run_update </dev/null || fail "an opted-in confirmed update reports a failure"
diff <(expected_steps confirmed omarchy-restart-shell plugins) <(steps_run) >"$test_tmp/order" ||
fail "an opted-in confirmed update runs a different set of steps" "$(cat "$test_tmp/order")"
[[ -z $(cat "$test_tmp/steps.plugin-args") ]] ||
fail "a confirmed update skips the plugin change review" "$(cat "$test_tmp/steps.plugin-args")"
pass "an opted-in confirmed update lets the person review each plugin change"

PLUGIN_UPDATES=1 FAILING_STEP=omarchy-plugin-update run_update -y ||
fail "a failed plugin update fails the system update"
diff <(expected_steps "" omarchy-restart-shell plugins) <(steps_run) >"$test_tmp/order" ||
fail "a failed plugin update skips later update steps" "$(cat "$test_tmp/order")"
grep -q "omarchy plugin update" "$test_tmp/err" || fail "the plugin update failure has no retry guidance"
pass "a plugin failure still finishes the update and explains how to retry"