feat: add custom pasteboard type for clipboard manager compatibility (macOS)#335
Open
jguice wants to merge 1 commit intoOpenWhispr:mainfrom
Open
feat: add custom pasteboard type for clipboard manager compatibility (macOS)#335jguice wants to merge 1 commit intoOpenWhispr:mainfrom
jguice wants to merge 1 commit intoOpenWhispr:mainfrom
Conversation
…(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>
d765184 to
b1ddcec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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.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) usesNSPasteboardto write bothpublic.utf8-plain-textand a customcom.openwhispr.transcriptiontype simultaneously. The existingclipboard.writeText()calls in the paste flow are replaced withwriteClipboardWithMarker(), which invokes this binary on macOS and falls back to standardclipboard.writeText()on other platforms or on failure.Users can add
com.openwhispr.transcriptionto their clipboard manager's ignored pasteboard types:com.openwhispr.transcriptionunder pasteboard typescom.openwhispr.transcriptionto the skip pasteboard types listCross-platform notes
writeClipboardWithMarker()falls through toclipboard.writeText().Future work: Linux and Windows clipboard marker support
A similar approach could be extended to the other platforms OpenWhispr supports:
application/x-openwhispr-transcriptioncould be written alongsidetext/plainusingxclip -selection clipboard -target(X11) or equivalent Wayland mechanisms (wl-copysupports--type). Clipboard managers like CopyQ support filtering by MIME type, so users could ignore the custom type.RegisterClipboardFormat(). A format likeOpenWhispr.Transcriptioncould be registered and written alongsideCF_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
resources/macos-clipboard-marker.swiftscripts/build-macos-clipboard-marker.jsbuild-macos-fast-paste.jspattern)src/helpers/clipboard.jswriteClipboardWithMarker()function; replacesclipboard.writeText(text)in paste flowsrc/helpers/audioManager.jssafePaste()package.jsoncompile:clipboard-markertocompile:nativechainelectron-builder.jsonmacos-clipboard-markerinextraResourcesREADME.mdTest plan
public.utf8-plain-textandcom.openwhispr.transcriptionare present on the pasteboard after dictationpbpastestill returns the transcribed text (standard paste unaffected)com.openwhispr.transcriptionis in its ignored types listclipboard.writeText()when binary is unavailable (covers Linux/Windows path)npm run lintpasses with no new warnings🤖 Generated with Claude Code