Skip to content

Copy untyped text as text/plain instead of a sniffed type - #90

Open
armandoclaudio wants to merge 1 commit into
typecraft-dev:mainfrom
armandoclaudio:fix/clipboard-text-type
Open

armandoclaudio wants to merge 1 commit into
typecraft-dev:mainfrom
armandoclaudio:fix/clipboard-text-type

Conversation

@armandoclaudio

@armandoclaudio armandoclaudio commented Nov 12, 2026 •

Copy link
Copy Markdown

Copying a one-character value from the launcher, such as the calculator result of 2+2, leaves a clipboard entry that can't be pasted as text. The entry never shows up in Omarchy's clipboard history either.

Cause

services/ClipboardWriter.qml sends the value to wl-copy on stdin with no --type, so wl-copy guesses the type from the bytes. A single character is guessed as application/octet-stream, and any value that starts like a file signature gets that file's type:

$ printf 4 | wl-copy; wl-paste --list-types
application/octet-stream

$ printf %%PDF-1.4 | wl-copy; wl-paste --list-types
application/pdf

$ printf 4 | wl-copy; wl-paste --type text
Clipboard content is not available as requested type "text"

Omarchy's clipboard history watches with wl-paste --type text, so it skips these entries, and so does any app that asks for text.

This came in with 5236a6f, which moved the value off the command line and onto stdin. That change is worth keeping. The old wl-copy -- "$text" form always offered text types; only the type needs to be stated now.

Fix

Since #85, both scripts take an optional MIME type in $1 and pass ${1:+--type "$1"}. Calculator results, emoji and other text copies pass none, so they are still sniffed. This changes the default to --type "${1:-text/plain}": text with no stated type goes out as text/plain, and Clipboard History's explicit types (image/png, text/uri-list, ...) pass through unchanged. wl-copy adds the other text types itself (text/plain;charset=utf-8, UTF8_STRING, TEXT, STRING), so non-ASCII results such as €92.50 still paste correctly. The privacy test now also checks that a copy with no type goes out as text/plain.

Testing

  • node --test tests/*.test.js: 184 passing, 3 skipped. The new assertion fails without the fix.
  • omarchy plugin validate . passes.
  • The new copyScript run by hand against the real wl-copy: 4 with no type offers text/plain, UTF8_STRING, etc. (bare wl-copy gives application/octet-stream), and text/uri-list stays text/uri-list.

Rebased onto main after #85 and #72 landed; the earlier version of this PR predated them.

Omarchy 4.5.0-3, wl-clipboard 2.3.0

ClipboardWriter's scripts pass ${1:+--type "$1"}, so calculator results,
emoji and other text copies go to wl-copy with no type, and wl-copy sniffs
stdin: "4" is offered only as application/octet-stream and "%PDF-1.4" only
as application/pdf, so neither pastes as text nor reaches Omarchy's
clipboard history. Default the type to text/plain; explicit types from
Clipboard History are unchanged.
@armandoclaudio armandoclaudio changed the title Copy calculator text as text/plain instead of a sniffed type Copy untyped text as text/plain instead of a sniffed type Nov 16, 2026
@armandoclaudio
armandoclaudio force-pushed the fix/clipboard-text-type branch from d1b236d to 7a22b06 Compare November 16, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant