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
4 changes: 2 additions & 2 deletions bin/omarchy-clipboard-paste-text
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions test/shell.d/clipboard-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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" \
Expand Down