From b06ae1371cfa6106fb1bfa4ae51c33f56a5387d9 Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Mon, 12 Oct 2026 12:06:52 +0200 Subject: [PATCH] Copy clipboard history text as text/plain Untyped, wl-copy asks xdg-mime to sniff the bytes, and some valid UTF-8 text (two spaces and a Cyrillic word) comes back as application/x-dtsz, so the restored entry offers no text type and text paste fails. Fixes #12662 Co-Authored-By: Claude Opus 5.5 --- bin/omarchy-clipboard-paste-text | 4 ++-- test/shell.d/clipboard-test.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/omarchy-clipboard-paste-text b/bin/omarchy-clipboard-paste-text index b8ac8e3127a7..f64297b14234 100755 --- a/bin/omarchy-clipboard-paste-text +++ b/bin/omarchy-clipboard-paste-text @@ -36,7 +36,7 @@ copy_history_entry() { [[ $history_index =~ ^[0-9]+$ ]] || exit jq -e --argjson index "$history_index" '.[$index].type == "text" and (.[$index].text | type == "string")' "$history_path" >/dev/null || exit - jq -j --argjson index "$history_index" '.[$index].text' "$history_path" | wl-copy + jq -j --argjson index "$history_index" '.[$index].text' "$history_path" | wl-copy --type "text/plain;charset=utf-8" } if [[ -n $history_index ]]; then @@ -47,7 +47,7 @@ if [[ -n $history_index ]]; then else text=${1:-} [[ -n $text ]] || exit - printf '%s' "$text" | wl-copy + printf '%s' "$text" | wl-copy --type "text/plain;charset=utf-8" fi if [[ $copy_only == "true" ]]; then diff --git a/test/shell.d/clipboard-test.sh b/test/shell.d/clipboard-test.sh index 17415ef0c31b..5c378aaac89b 100644 --- a/test/shell.d/clipboard-test.sh +++ b/test/shell.d/clipboard-test.sh @@ -249,6 +249,7 @@ mkdir -p "$TMPDIR/bin" "$TMPDIR/home/.local/state/omarchy" cat >"$TMPDIR/bin/wl-copy" <<'SH' #!/bin/bash +printf '%s\n' "$*" >"$WL_COPY_OUT.args" cat >"$WL_COPY_OUT" SH @@ -536,6 +537,16 @@ pass "clipboard paste helper copy-only copies history entry text" [[ ! -e "$TMPDIR/wtype" ]] || fail "clipboard paste helper copy-only skips typing" pass "clipboard paste helper copy-only skips typing" +# Untyped, wl-copy sniffs the bytes and can offer text like $' Тест\n' as application/x-dtsz +[[ $(<"$TMPDIR/copied.args") == "--type text/plain;charset=utf-8" ]] || fail "clipboard paste helper copies history text as text/plain" +pass "clipboard paste helper copies history text as text/plain" + +WL_COPY_OUT="$TMPDIR/copied" WTYPE_OUT="$TMPDIR/wtype" PATH="$TMPDIR/bin:$PATH" \ + "$ROOT/bin/omarchy-clipboard-paste-text" --copy-only "$(printf ' \u0422\u0435\u0441\u0442')" + +[[ $(<"$TMPDIR/copied.args") == "--type text/plain;charset=utf-8" ]] || fail "clipboard paste helper copies given text as text/plain" +pass "clipboard paste helper copies given text as text/plain" + printf 'image-data' >"$TMPDIR/image.png" rm -f "$TMPDIR/wtype" WL_COPY_OUT="$TMPDIR/copied" WTYPE_OUT="$TMPDIR/wtype" PATH="$TMPDIR/bin:$PATH" \