bench, docs: let the client detect readiness; say what Enter commits

bench.sh copied ipcpath() and the IBus address-file discovery into shell,
although the benchmark client only speaks IPC; retrying the client itself
is the readiness test. It also forwarded arguments to a daemon that takes
exactly one. README claimed Enter confirms the selection, but Enter and Tab
commit the reading unless a candidate was moved to.
This commit is contained in:
2026-08-16 15:46:28 +09:00
parent d3c9813f6e
commit 66ea2892f8
2 changed files with 15 additions and 59 deletions

View File

@@ -18,10 +18,10 @@ Vietnamese Telex is also available as a compatibility mode.
Use `Up`/`Down` to move through candidates and `PageUp`/`PageDown` to move by
nine without wrapping. An unmodified `1`-`9` selects that row on the current
page. `Enter` confirms the selection, and `0` commits the current reading
without conversion. `Tab` confirms an ordinary candidate; in a temporary
Emoji or Hanja search, `Tab` and `Shift-Tab` wrap through the results. `Esc`
cancels composition.
page. `Enter` and `Tab` commit a candidate you have moved to; otherwise they
commit the reading, as `0` always does. In a temporary Emoji or Hanja search,
`Enter` commits the highlighted result and `Tab`/`Shift-Tab` wrap through
the results. `Esc` cancels composition.
Hiragana mode composes a complete reading before offering Kanji candidates.
Katakana mode does not perform Kanji conversion. Emoji and Hanja searches

View File

@@ -4,18 +4,8 @@ set -eu
cd "$(dirname "$0")" || exit 1
case ${XDG_RUNTIME_DIR-} in
/) ipc=/strans.sock ;;
/*/) ipc=${XDG_RUNTIME_DIR}strans.sock ;;
/*) ipc=${XDG_RUNTIME_DIR}/strans.sock ;;
*) ipc=/tmp/strans.$(id -u) ;;
esac
if test -n "${XDG_CONFIG_HOME-}"; then
busdir=$XDG_CONFIG_HOME/ibus/bus
elif test "${HOME+x}" = x; then
busdir=$HOME/.config/ibus/bus
else
echo "bench.sh: HOME or XDG_CONFIG_HOME is required for IBus discovery" >&2
if test "$#" -ne 0; then
echo "usage: bench.sh" >&2
exit 1
fi
@@ -29,70 +19,36 @@ cleanup()
if test -n "$perf_pid"; then
kill -INT "$perf_pid" 2>/dev/null || :
wait "$perf_pid" 2>/dev/null || :
perf_pid=
fi
if test -n "$strans_pid"; then
kill "$strans_pid" 2>/dev/null || :
wait "$strans_pid" 2>/dev/null || :
strans_pid=
fi
exit "$status"
}
ibusready()
{
for address in "$busdir"/*; do
test -f "$address" || continue
foundpid=
foundaddress=
while IFS= read -r line; do
case $line in
IBUS_DAEMON_PID="$strans_pid") foundpid=1 ;;
IBUS_ADDRESS=unix:abstract=strans-"$strans_pid",*) foundaddress=1 ;;
esac
done <"$address"
if test -n "$foundpid" && test -n "$foundaddress"; then
return 0
fi
done
return 1
}
trap cleanup 0
trap 'exit 129' 1
trap 'exit 130' 2
trap 'exit 143' 15
./strans map "$@" &
./strans map &
strans_pid=$!
# The daemon is ready once the benchmark client can complete a round.
attempt=0
while test "$attempt" -lt 10; do
if test -S "$ipc" && ibusready; then
break
fi
until ./bench/bench bench/bench.keys 1 >/dev/null 2>&1; do
if ! kill -0 "$strans_pid" 2>/dev/null; then
if wait "$strans_pid"; then
status=0
else
status=$?
fi
strans_pid=
if test "$status" -eq 0; then
status=1
fi
echo "bench.sh: daemon exited before publishing IPC and IBus endpoints" >&2
exit "$status"
fi
attempt=$((attempt + 1))
if test "$attempt" -lt 10; then
sleep 1
fi
done
if test "$attempt" -eq 10; then
echo "bench.sh: daemon did not publish IPC and IBus endpoints within 10 seconds" >&2
echo "bench.sh: daemon exited before accepting IPC clients" >&2
exit 1
fi
attempt=$((attempt + 1))
if test "$attempt" -ge 50; then
echo "bench.sh: daemon did not accept IPC clients within 10 seconds" >&2
exit 1
fi
sleep 0.2
done
# warm up the renderer
./bench/bench bench/bench.keys 100