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
2 changes: 1 addition & 1 deletion bin/omarchy-clipboard-paste-file
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ if [[ $copy_only == "true" ]]; then
fi

sleep 0.15
wtype -M shift -k Insert -m shift 2>/dev/null || true
wtype -M ctrl -k v -m ctrl 2>/dev/null || true
19 changes: 19 additions & 0 deletions test/shell.d/clipboard-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,25 @@ pass "clipboard file paste helper copy-only copies file content"
[[ ! -e "$TMPDIR/wtype" ]] || fail "clipboard file paste helper copy-only skips paste keystroke"
pass "clipboard file paste helper copy-only skips paste keystroke"

rm -f "$TMPDIR/wtype"
WL_COPY_OUT="$TMPDIR/copied" WTYPE_OUT="$TMPDIR/wtype" PATH="$TMPDIR/bin:$PATH" \
"$ROOT/bin/omarchy-clipboard-paste-file" image/png "$TMPDIR/image.png"

[[ $(<"$TMPDIR/copied") == "image-data" ]] || fail "clipboard file paste helper copies file content"
pass "clipboard file paste helper copies file content"

[[ $(<"$TMPDIR/wtype") == "-M ctrl -k v -m ctrl" ]] || fail "clipboard file paste helper pastes files with ctrl v"
pass "clipboard file paste helper pastes files with ctrl v"

(! PATH="$TMPDIR/bin:$PATH" "$ROOT/bin/omarchy-clipboard-paste-file" 2>/dev/null) || fail "clipboard file paste helper fails on missing arguments"
pass "clipboard file paste helper fails on missing arguments"

rm -f "$TMPDIR/copied" "$TMPDIR/wtype"
(! PATH="$TMPDIR/bin:$PATH" "$ROOT/bin/omarchy-clipboard-paste-file" image/png "$TMPDIR/nonexistent.png" 2>/dev/null) || fail "clipboard file paste helper fails on unreadable file"
[[ ! -e "$TMPDIR/copied" ]] || fail "clipboard file paste helper does not copy unreadable file"
[[ ! -e "$TMPDIR/wtype" ]] || fail "clipboard file paste helper does not paste when file unreadable"
pass "clipboard file paste helper fails safely on unreadable file"

jq -n --arg url 'https://example.com/docs' --arg text "$(printf 'plain text\nsecond line')" --arg image "$TMPDIR/image.png" \
'[{type:"text", text:$url}, {type:"text", text:$text}, {type:"image", mime:"image/png", path:$image}]' >"$TMPDIR/home/.local/state/omarchy/clipboard-history.json"

Expand Down