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
8 changes: 6 additions & 2 deletions bin/omarchy-install-ai-openclaw
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

set -e

echo "Installing OpenClaw..."
omarchy-pkg-add openclaw
if omarchy-openclaw-present; then
echo "OpenClaw is already available; skipping the package install."
else
echo "Installing OpenClaw..."
omarchy-pkg-add openclaw
fi

# The desktop app is OpenClaw's Control UI: a web app served by its own
# gateway. The launcher entry goes through omarchy-launch-openclaw, which
Expand Down
18 changes: 9 additions & 9 deletions bin/omarchy-install-openclaw-cli
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
# omarchy:args=[--check|--now]
# omarchy:requires-sudo=true

# OpenClaw is not a mise tool: the openclaw pacman package is the one OpenClaw
# installation on the machine — the CLI, the gateway, and the Install > AI web
# app all share it, and the fast ring keeps it current. The default-agent flow
# talks to that package through the same --check/--now contract mise-backed
# agents get from mise itself.
# OpenClaw is not a mise tool: the openclaw pacman package is the usual
# Omarchy install, but a user may already have a newer CLI on PATH. Treat any
# working openclaw (package, PATH, or gateway) as present so --check/--now
# does not reinstall a stale package ahead of it.

set -euo pipefail

case "${1:---now}" in
--check)
omarchy-pkg-present openclaw
omarchy-openclaw-present
;;
--now)
if ! omarchy-pkg-present openclaw; then
echo "Installing OpenClaw..."
omarchy-pkg-add openclaw
if omarchy-openclaw-present; then
exit 0
fi
echo "Installing OpenClaw..."
omarchy-pkg-add openclaw
;;
*)
echo "Usage: omarchy-install-openclaw-cli [--check|--now]" >&2
Expand Down
12 changes: 12 additions & 0 deletions bin/omarchy-launch-openclaw
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@

set -euo pipefail

# /usr/bin usually precedes ~/.npm-global/bin. When both a packaged and a
# user-installed openclaw are on PATH, bare `openclaw` can be the older one
# and refuse a migrated state database. Surface that before we talk to it.
_openclaw_bins=()
while IFS= read -r _openclaw_bin; do
_openclaw_bins+=("$_openclaw_bin")
done < <(type -aP openclaw 2>/dev/null || true)
if ((${#_openclaw_bins[@]} > 1)); then
echo "warning: multiple openclaw binaries on PATH; using ${_openclaw_bins[0]}" >&2
printf ' %s\n' "${_openclaw_bins[@]}" >&2
fi

tui=false
message=()
if [[ ${1:-} == "--tui" ]]; then
Expand Down
28 changes: 28 additions & 0 deletions bin/omarchy-openclaw-present
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# omarchy:summary=True when OpenClaw is already available (package, PATH, or gateway)
# omarchy:hidden=true

# The Install > AI entry used to key only on the pacman package. A newer
# OpenClaw installed outside the package (npm, a manual build) still puts
# `openclaw` on PATH and may already be running a gateway. Re-offering the
# package in that state can put an older /usr/bin/openclaw ahead of the
# working one and break a migrated state database.

if omarchy-pkg-present openclaw 2>/dev/null; then
exit 0
fi

if command -v openclaw >/dev/null 2>&1; then
exit 0
fi

if systemctl --user is-enabled --quiet openclaw-gateway.service 2>/dev/null; then
exit 0
fi

if [[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/openclaw-gateway.service ]]; then
exit 0
fi

exit 1
2 changes: 1 addition & 1 deletion default/omarchy/omarchy-menu.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
"install.ai.hermes": {"icon":"","iconFont":"omarchy","label":"Hermes Desktop","disabled":"omarchy-pkg-present hermes-desktop","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-hermes"},
"install.ai.lm-studio": {"icon":"","iconFont":"omarchy","label":"LM Studio","disabled":"omarchy-pkg-present lmstudio-bin","action":"omarchy-install-app 'LM Studio' lmstudio-bin"},
"install.ai.ollama": {"icon":"","iconFont":"omarchy","label":"Ollama","disabled":"omarchy-cmd-present ollama","action":"if omarchy-cmd-present nvidia-smi; then ollama_pkg=ollama-cuda; elif omarchy-cmd-present rocminfo; then ollama_pkg=ollama-rocm; else ollama_pkg=ollama; fi; omarchy-install-app Ollama \"$ollama_pkg\""},
"install.ai.openclaw": {"icon":"","iconFont":"omarchy","label":"OpenClaw","disabled":"omarchy-pkg-present openclaw","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-openclaw"},
"install.ai.openclaw": {"icon":"","iconFont":"omarchy","label":"OpenClaw","disabled":"omarchy-openclaw-present","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-openclaw"},
"install.ai.perplexity": {"icon":"","iconFont":"omarchy","label":"Perplexity","disabled":"omarchy-pkg-present perplexity","action":"omarchy-install-and-launch Perplexity perplexity perplexity"},
"install.ai.t3-code": {"icon":"","iconFont":"omarchy","label":"T3 Code","disabled":"omarchy-pkg-present t3code-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-t3-code"},
"install.gaming.steam": {"icon":"","label":"Steam","disabled":"omarchy-pkg-present steam","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-gaming-steam"},
Expand Down
15 changes: 9 additions & 6 deletions test/shell.d/default-agent-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,13 @@ cat >"$mock_bin/omarchy-pkg-present" <<'SH'
#!/bin/bash
[[ $1 == openclaw && ${OMARCHY_TEST_OPENCLAW_INSTALLED:-false} == "true" ]]
SH
# install-openclaw-cli now asks omarchy-openclaw-present (package, PATH, or
# gateway). Drive that with the same fixture flag so a leftover openclaw stub
# cannot masquerade as an install.
cat >"$mock_bin/omarchy-openclaw-present" <<'SH'
#!/bin/bash
[[ ${OMARCHY_TEST_OPENCLAW_INSTALLED:-false} == "true" ]]
SH
cat >"$mock_bin/omarchy-pkg-add" <<'SH'
#!/bin/bash
printf '%s\n' "pkg-add $*" >>"$OMARCHY_TEST_STUB_LOG"
Expand All @@ -751,12 +758,8 @@ cat >"$mock_bin/omarchy-launch-openclaw" <<'SH'
#!/bin/bash
printf '%s\0' omarchy-launch-openclaw "$@" >"$OMARCHY_TEST_AGENT_INLINE_LOG"
SH
cat >"$mock_bin/openclaw" <<'SH'
#!/bin/bash
exit 0
SH
chmod +x "$mock_bin/omarchy-pkg-present" "$mock_bin/omarchy-pkg-add" \
"$mock_bin/omarchy-launch-openclaw" "$mock_bin/openclaw"
chmod +x "$mock_bin/omarchy-pkg-present" "$mock_bin/omarchy-openclaw-present" \
"$mock_bin/omarchy-pkg-add" "$mock_bin/omarchy-launch-openclaw"

: >"$launch_log"
: >"$terminal_log"
Expand Down
70 changes: 70 additions & 0 deletions test/shell.d/openclaw-present-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

set -euo pipefail

source "$(dirname "$0")/base-test.sh"

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/bin" "$tmp/home/.config/systemd/user"
export HOME="$tmp/home"
export XDG_CONFIG_HOME="$tmp/home/.config"
export PATH="$tmp/bin:$ROOT/bin:/usr/bin:/bin"
export TEST_LOG="$tmp/log"
: >"$TEST_LOG"

cat >"$tmp/bin/omarchy-pkg-present" <<'SH'
#!/bin/bash
exit 1
SH
chmod +x "$tmp/bin/omarchy-pkg-present"

cat >"$tmp/bin/systemctl" <<'SH'
#!/bin/bash
exit 1
SH
chmod +x "$tmp/bin/systemctl"

if omarchy-openclaw-present; then
fail "absent OpenClaw should not count as present"
fi
pass "absent OpenClaw is not present"

cat >"$tmp/bin/openclaw" <<'SH'
#!/bin/bash
exit 0
SH
chmod +x "$tmp/bin/openclaw"

omarchy-openclaw-present || fail "PATH openclaw should count as present"
pass "PATH openclaw counts as present"

cat >"$tmp/bin/omarchy-pkg-add" <<'SH'
#!/bin/bash
printf 'pkg-add:%s\n' "$*" >>"$TEST_LOG"
exit 0
SH
chmod +x "$tmp/bin/omarchy-pkg-add"

omarchy-install-openclaw-cli --check || fail "--check should succeed for PATH openclaw"
omarchy-install-openclaw-cli --now || fail "--now should succeed without installing"
if [[ -s $TEST_LOG ]]; then
fail "--now must not reinstall over a PATH openclaw" "$(cat "$TEST_LOG")"
fi
pass "install-openclaw-cli leaves a PATH openclaw alone"

rm -f "$tmp/bin/openclaw"
touch "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service"
omarchy-openclaw-present || fail "gateway unit should count as present"
pass "gateway unit counts as present"

# Shadowed PATH warning (exercise the detection the launcher uses).
rm -f "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service"
mkdir -p "$tmp/a" "$tmp/b"
printf '#!/bin/bash\n' >"$tmp/a/openclaw"
printf '#!/bin/bash\n' >"$tmp/b/openclaw"
chmod +x "$tmp/a/openclaw" "$tmp/b/openclaw"
export PATH="$tmp/a:$tmp/b:$tmp/bin:$ROOT/bin:/usr/bin:/bin"
mapfile -t bins < <(type -aP openclaw)
(( ${#bins[@]} > 1 )) || fail "fixture should expose two openclaw binaries"
pass "multiple openclaw binaries are detectable on PATH"