Skip to content

Map Linux clipboard MIME types to macOS UTIs - #4

Open
sud0n1m wants to merge 1 commit into
standardagents:mainfrom
sud0n1m:normalize-macos-clipboard-formats
Open

Map Linux clipboard MIME types to macOS UTIs#4
sud0n1m wants to merge 1 commit into
standardagents:mainfrom
sud0n1m:normalize-macos-clipboard-formats

Conversation

@sud0n1m

@sud0n1m sud0n1m commented Aug 21, 2026

Copy link
Copy Markdown

Problem

Linux Wayland/X11 clipboards advertise types such as text/plain, text/plain;charset=utf-8, UTF8_STRING, and image/png. macOS NSPasteboard only accepts UTIs. Applying those names as-is logs:

'text/plain' is not a valid UTI string. Cannot set data for an invalid UTI.

and then native clipboard was empty immediately after publishing. Mac → Linux still works because capture already adds portable aliases.

Reproduced on ssh-clipboard 0.2.8 between Omarchy (Hyprland/Wayland) and macOS 26, with a healthy persistent SSH bridge.

Change

On macOS apply:

  • Map known portable formats to UTIs (text/plainpublic.utf8-plain-text, image/pngpublic.png, and the rest of the existing alias table in reverse).
  • Collapse equivalent formats so the pasteboard gets one native type.
  • Skip remaining non-UTI names (STRING, TEXT, custom MIME) instead of handing them to NSPasteboard.

Linux capture is unchanged. This is the apply-side half of the portable alias table already documented for macOS capture.

Test plan

  • Unit tests for mapping and duplicate collapse
  • Copy UTF-8 text Wayland → NSPasteboard; pbpaste matches
  • Copy UTF-8 text NSPasteboard → Wayland; wl-paste matches
  • Copy a PNG Wayland → NSPasteboard; clipboard info includes PNGf

NSPasteboard rejects Wayland/X11 type names such as text/plain,
image/png, and UTF8_STRING. Copies from Linux therefore published
an empty pasteboard even when the SSH bridge was healthy.

Normalize known portable formats to UTIs before publish, collapse
duplicates, and skip remaining non-UTI types.
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