Skip to content

Support pasting Omarchy screenshots into terminals - #7422

Open
swheel33 wants to merge 2 commits into
basecamp:quattrofrom
swheel33:file-backed-terminal-image-paste
Open

Support pasting Omarchy screenshots into terminals#7422
swheel33 wants to merge 2 commits into
basecamp:quattrofrom
swheel33:file-backed-terminal-image-paste

Conversation

@swheel33

Copy link
Copy Markdown

Omarchy screenshots currently place only image/png on the clipboard. Graphical applications can paste the image, but terminals cannot request a usable file path.

This mirrors the user-facing behavior of CleanShot X on macOS: a captured screenshot pastes as an image into graphical applications and as its backing file path into terminals.

Screenshots are now published as one clipboard selection with multiple representations:

  • image/png for graphical applications
  • text/plain for terminals
  • text/uri-list for file-aware applications
  • an internal marker used by clipboard history

Copy-only screenshots are stored in a content-addressed cache under $XDG_STATE_HOME/omarchy/clipboard-images. Saved screenshots use their existing file directly.

The clipboard provider remains alive only while it owns the selection and exits through GDK native detach lifecycle when another application or screenshot replaces it. Clipboard history records the image while suppressing the duplicate generated path entry.

Why this approach

Related to #7187, but this keeps the existing Super+V binding unchanged and limits the change to screenshots created by Omarchy.

Rather than inspecting the clipboard during paste and synthesizing a different shortcut, each receiving application selects the representation it already understands:

  • terminals receive the backing file path
  • graphical applications receive the PNG
  • file-aware applications receive the file URI

This avoids focus and synthetic-key timing concerns while preserving normal text paste behavior.

Scope and limitations

This applies only to screenshots created by Omarchy because their backing files are known at capture time.

Images copied from browsers or other applications are not converted into file-backed clipboard entries. They still require Ctrl+V in terminals that support direct image paste.

Making Super+V handle arbitrary copied images would require the broader clipboard interception or conditional key-dispatch behavior discussed in #7187. That is intentionally outside this change.

Tests

  • ./test/cli
  • test/shell.d/clipboard-publish-image-test.sh
  • test/shell.d/screenshot-clipboard-test.sh
  • test/shell.d/clipboard-test.sh
  • Bash syntax checks
  • Python compilation
  • git diff --check
  • Real Wayland verification of advertised MIME types, exact PNG bytes, consecutive screenshot replacement, and provider exit after clipboard replacement
  • Dev-linked desktop test using the normal screenshot hotkey:
    • Super+V pasted the backing path into a terminal
    • Ctrl+V pasted the screenshot into a graphical application

The full ./test/shell run completed with four unrelated local-environment failures: one bar geometry check and three checks requiring an omarchy-pkgs checkout.

Copilot AI balanced review requested due to automatic review settings August 18, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds file-backed screenshot clipboard representations for terminal, graphical, and file-aware applications.

Changes:

  • Adds a GTK clipboard provider with multiple MIME representations.
  • Stores copy-only screenshots in a content-addressed cache.
  • Suppresses duplicate clipboard-history path entries and adds coverage.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
bin/omarchy-capture-screenshot Captures cached images and launches the provider.
bin/omarchy-clipboard-publish-image Adds the provider command wrapper.
shell/plugins/clipboard/publish-image.py Publishes image, path, URI, and marker payloads.
shell/plugins/clipboard/capture.sh Suppresses duplicate history text entries.
test/acceptance.d/screenshot-clipboard-test.sh Verifies Wayland clipboard behavior and lifecycle.
test/shell.d/clipboard-publish-image-test.sh Tests provider payloads and runtime selection.
test/shell.d/clipboard-test.sh Tests history suppression.
test/shell.d/screenshot-clipboard-test.sh Tests screenshot publication and caching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +69 to +71
# File-backed screenshots expose their path for terminal paste. The image
# watcher records the same selection, so do not add a duplicate text entry.
grep -qx 'application/x-omarchy-file-backed-image' <<<"$types" || emit_text

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid catch, fixed in 0a8f39c. Marked screenshot selections now persist fileBacked: true on the image history entry, preserve it through normalization and the display model, and restore through the multi-representation publisher. Ordinary image history entries still use image-only wl-copy, so the PR scope remains unchanged. I also centralized provider detachment/readiness in omarchy-clipboard-publish-image and added focused coverage for capture, metadata propagation, and both restoration paths.

Copilot AI review requested due to automatic review settings August 18, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (1)

shell/plugins/clipboard/capture.sh:41

  • types describes the clipboard selection that is current when this subprocess runs, not necessarily the selection whose image is arriving on stdin from wl-paste --watch. If a screenshot is replaced quickly, this invocation can see the replacement's MIME list and omit fileBacked; the analogous check in emit_text can then also record the screenshot path as a duplicate. The reverse ordering can mark/suppress an ordinary clipboard event. Associate the marker with the watched event itself rather than re-querying the mutable global selection, and add a rapid-replacement regression test.
  grep -qx 'application/x-omarchy-file-backed-image' <<<"$types" && file_backed=true

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.

2 participants