Skip to content

feat: add custom pasteboard type for clipboard manager compatibility (macOS)#335

Open
jguice wants to merge 1 commit intoOpenWhispr:mainfrom
jguice:feature/clipboard-manager-pasteboard-marker
Open

feat: add custom pasteboard type for clipboard manager compatibility (macOS)#335
jguice wants to merge 1 commit intoOpenWhispr:mainfrom
jguice:feature/clipboard-manager-pasteboard-marker

Conversation

@jguice
Copy link

@jguice jguice commented Feb 27, 2026

Note: I'm testing this locally on macOS (Apple Silicon) and it's working well, but wanted to share for early feedback.

Summary

  • Clipboard manager compatibility (macOS): Adds a custom pasteboard type (com.openwhispr.transcription) alongside the plain text when OpenWhispr writes to the clipboard during paste operations. This allows clipboard managers that support pasteboard type filtering (Maccy, Flycut) to identify and ignore OpenWhispr's transient clipboard writes.
  • Trailing space after dictation: Appends a trailing space after pasted transcriptions so the cursor is positioned ready for the next word, matching the behaviour of other dictation tools (e.g. WhisperFlow). This is a small UX improvement that makes back-to-back dictations and dictation-then-typing flows smoother.
  • Cross-platform safe: Linux and Windows functionality is completely unchanged — the pasteboard marker is macOS-only, and the code gracefully falls back to the existing clipboard.writeText() on all other platforms.

Problem

OpenWhispr briefly writes transcribed text to the system clipboard, then simulates Cmd+V to paste into the active app, and finally restores the original clipboard contents. Clipboard managers (e.g. Maccy, Flycut) capture these transient writes. Because the paste is simulated via Cmd+V in the foreground app, macOS clipboard managers typically attribute the entry to the foreground app rather than OpenWhispr, making app-based filtering unreliable.

Solution

A small compiled Swift helper (macos-clipboard-marker) uses NSPasteboard to write both public.utf8-plain-text and a custom com.openwhispr.transcription type simultaneously. The existing clipboard.writeText() calls in the paste flow are replaced with writeClipboardWithMarker(), which invokes this binary on macOS and falls back to standard clipboard.writeText() on other platforms or on failure.

Users can add com.openwhispr.transcription to their clipboard manager's ignored pasteboard types:

  • Maccy: Settings → Ignore → add com.openwhispr.transcription under pasteboard types
  • Flycut: Preferences → add com.openwhispr.transcription to the skip pasteboard types list

Cross-platform notes

  • macOS: Full pasteboard marker support via compiled Swift helper
  • Linux: No changes to clipboard behaviour. The build script is a no-op on non-macOS. writeClipboardWithMarker() falls through to clipboard.writeText().
  • Windows: Same as Linux — no changes, standard clipboard path used.

Future work: Linux and Windows clipboard marker support

A similar approach could be extended to the other platforms OpenWhispr supports:

  • Linux (X11/Wayland): The clipboard supports MIME types as targets alongside content. A custom MIME type like application/x-openwhispr-transcription could be written alongside text/plain using xclip -selection clipboard -target (X11) or equivalent Wayland mechanisms (wl-copy supports --type). Clipboard managers like CopyQ support filtering by MIME type, so users could ignore the custom type.
  • Windows: The clipboard supports custom formats via RegisterClipboardFormat(). A format like OpenWhispr.Transcription could be registered and written alongside CF_UNICODETEXT. The open-source clipboard manager Ditto exposes format information, though filtering support would need investigation.

Both would follow the same pattern: write a platform-specific marker alongside the text so clipboard managers can identify and optionally ignore transient dictation entries, with a graceful fallback to standard clipboard writes if the marker mechanism is unavailable.

Changes

File Change
resources/macos-clipboard-marker.swift New Swift source for the pasteboard marker binary
scripts/build-macos-clipboard-marker.js Build script (follows existing build-macos-fast-paste.js pattern)
src/helpers/clipboard.js writeClipboardWithMarker() function; replaces clipboard.writeText(text) in paste flow
src/helpers/audioManager.js Appends trailing space in safePaste()
package.json Adds compile:clipboard-marker to compile:native chain
electron-builder.json Includes macos-clipboard-marker in extraResources
README.md Troubleshooting entry for clipboard manager configuration

Test plan

  • Verified on macOS (Apple Silicon) that both public.utf8-plain-text and com.openwhispr.transcription are present on the pasteboard after dictation
  • Confirmed pbpaste still returns the transcribed text (standard paste unaffected)
  • Confirmed Maccy ignores dictation entries when com.openwhispr.transcription is in its ignored types list
  • Verified trailing space is appended after pasted transcriptions
  • Verified fallback to clipboard.writeText() when binary is unavailable (covers Linux/Windows path)
  • Confirmed clipboard restore (original content) after paste does not include the marker type
  • npm run lint passes with no new warnings
  • Build script exits cleanly on non-macOS platforms

🤖 Generated with Claude Code

@jguice jguice marked this pull request as draft February 27, 2026 14:02
@jguice jguice marked this pull request as ready for review March 5, 2026 21:22
…(macOS)

OpenWhispr briefly writes transcribed text to the system clipboard before
simulating a paste. Clipboard managers (e.g. Maccy, Paste, CopyClip) capture
these transient writes, cluttering their history. Because the paste is
simulated via Cmd+V in the foreground app, clipboard managers attribute the
entry to that app rather than OpenWhispr, making app-based filtering
impossible.

This adds a compiled Swift helper (macos-clipboard-marker) that writes both
the plain text and a custom pasteboard type (com.openwhispr.transcription)
to the macOS pasteboard simultaneously. Users can add this type to their
clipboard manager's ignore list to filter out dictation entries.

Also appends a trailing space after pasted transcriptions so the cursor is
positioned ready for the next word, matching the behaviour of other
dictation tools like WhisperFlow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jguice jguice force-pushed the feature/clipboard-manager-pasteboard-marker branch from d765184 to b1ddcec Compare March 5, 2026 21:27
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