Skip to content
Closed
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
11 changes: 11 additions & 0 deletions bin/omarchy-plugin-list
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ done

plugins=$(omarchy-shell shell listPlugins)

# The qs ipc client prints Qt diagnostics on stdout -- since Qt 6.12, the
# non-UTF-8 locale warning lands there ahead of the payload (#15834). Skip to
# the JSON array; a call that never produced one is an error, not an empty
# plugin list.
stripped=$(printf '%s\n' "$plugins" | sed -n '/^\[/,$p')
if [[ -z $stripped ]]; then
echo "omarchy-plugin-list: omarchy-shell returned no plugin list" >&2
exit 1
fi
plugins=$stripped

if [[ $json == "true" ]]; then
printf '%s\n' "$plugins"
exit 0
Expand Down
77 changes: 77 additions & 0 deletions test/shell.d/plugin-list-locale-warning-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

set -euo pipefail

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

require_command jq

TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT

STUB_DIR="$TMPDIR/stub"
mkdir -p "$STUB_DIR"

# Qt diagnostics reach stdout ahead of the payload: since Qt 6.12, the
# non-UTF-8 locale warning prints on the qs ipc client's stdout (#15834), so
# omarchy-shell is stubbed to emit that preamble before the plugin JSON.
cat >"$STUB_DIR/omarchy-shell" <<'STUB'
#!/bin/bash
printf ' WARN: Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.\n'
printf 'Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.\n'
cat "$FAKE_PLUGINS"
STUB
chmod +x "$STUB_DIR/omarchy-shell"

cat >"$TMPDIR/plugins.json" <<'JSON'
[
{"id": "omarchy.clock", "name": "Clock", "kinds": ["bar-widget"], "enabled": true, "firstParty": true}
]
JSON

list() {
PATH="$STUB_DIR:$PATH" FAKE_PLUGINS="$TMPDIR/plugins.json" \
"$ROOT/bin/omarchy-plugin-list" "$@"
}

out=$(list)
[[ $out == *"omarchy.clock"* ]] \
|| fail "the table skips the Qt locale warning and lists the plugin" "$out"
pass "the table skips the Qt locale warning and lists the plugin"

out=$(list --json)
[[ $out == \[* ]] \
|| fail "--json output starts with the payload, not the warning" "$out"
pass "--json output starts with the payload, not the warning"

# A clean payload keeps working.
cat >"$STUB_DIR/omarchy-shell" <<'STUB'
#!/bin/bash
cat "$FAKE_PLUGINS"
STUB
chmod +x "$STUB_DIR/omarchy-shell"

cat >"$TMPDIR/plugins.json" <<'JSON'
[
{"id": "acme.weather", "name": "Weather", "kinds": ["bar-widget"], "enabled": false, "firstParty": false}
]
JSON

out=$(list)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
[[ $out == *"acme.weather"* ]] || fail "a clean payload still lists its plugin" "$out"
out=$(list --json)
[[ $(jq -r '.[0].id' <<<"$out") == "acme.weather" ]] || fail "a clean payload passes through --json whole" "$out"
pass "a clean payload still lists its plugin"

# No JSON at all is an error, not an empty plugin list.
cat >"$STUB_DIR/omarchy-shell" <<'STUB'
#!/bin/bash
printf ' WARN: Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.\n'
STUB
chmod +x "$STUB_DIR/omarchy-shell"

status=0
out=$(list 2>&1) || status=$?
(( status != 0 )) || fail "a payload that never arrives is an error" "$out"
[[ $out == *"no plugin list"* ]] || fail "the missing payload says so on stderr" "$out"
pass "a payload that never arrives is an error, not an empty list"