fix(paste-helper): try plain wl-paste FIRST when image MIME advertised#153
Merged
NagyVikt merged 1 commit intoMay 16, 2026
Conversation
The PR #148 helper iterates `wl-paste --type <mime>` for each advertised image MIME. That works for most sources, but hits an intermittent gnome-screenshot quirk where `wl-paste --type image/png` returns the literal text "No suitable type of content copied" (35 bytes, no PNG magic) even though `image/png` is in --list-types and plain `wl-paste` DOES return the actual PNG bytes. Also: Wayland clipboard sources can be one-shot — once `wl-paste --type X` consumes the source, a subsequent plain `wl-paste` returns 0 bytes. So the fallback HAS to run BEFORE the --type loop, not after. New section (1a) before the existing (1) IMG_PREF loop: - Gated on at least one image MIME being advertised (so we don't swallow text content here) - Single plain `wl-paste` call into a temp file - Magic-byte sniff for PNG/JPEG/GIF/WebP/BMP/AVIF/HEIC/HEIF - On match: save with detected extension, paste the path, log outcome=image-no-type, exit 0 - On no match / empty / too-small: fall through to the existing (1) IMG_PREF loop which still works for sources that allow re-reads Smoke-tested against the project's actual clipboard mid-session. Synthetic `wl-copy --type X` doesn't repro the real bug cleanly, so relied on field repro via the user's prior `/tmp/clipboard-img-...png` that captured 35 bytes of the error text.
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.
Automated by gx branch finish (PR flow).