feat: add type metadata and subcommand for clipboard entries - #183
Open
xeorain wants to merge 1 commit into
Open
feat: add type metadata and subcommand for clipboard entries#183xeorain wants to merge 1 commit into
xeorain wants to merge 1 commit into
Conversation
Change the database value format by prefixing raw clipboard data with a type header. The type distinguishes text data from binary data (currently images). Add a `type` subcommand to retrieve the data type by record ID. This avoids relying on `wl-copy` MIME type inference when restoring clipboard data by piping the output of `cliphist decode` to `wl-copy`. Certain text data can be identified as incorrect MIME type in some edge cases. Related: bugaevc/wl-clipboard#294
Owner
Author
|
Thanks, @sentriz, I totally understand your standpoint of avoiding breaking changes, although I think most of users may not keep their clipboard history permanently. I will be looking forward to the sidecar bucket implementation, as it can also help improve the efficiency for |
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.
Motivation
When the output of
cliphist decodeis piped towl-copy,wl-copyneeds todetermine the MIME type of the input data. Currently,
wl-copyinvokesxdg-mimeto infer the MIME type, while allowing the--typeoption to specify a MIME type explicitly instead of relying on the internal inference. However, there are edge cases where plain text data is incorrectly identified as a non-text MIME type bywl-copy.See: bugaevc/wl-clipboard#294
Changes
This patch simply prepends a 1-byte type indicator header to the stored clipboard data to distinguish text data from binary data. Values are now stored in the form of
[type-indicator][payload]in the database.The
cliphist type <id>command can be used to query the type of a storedclipboard entry by its record id, allowing the clipboard restoration scripts to provide a more accurate MIME type to
wl-copy. Below is a typical example ofthe usage:
Although the issue is triggered by the MIME type inference in
wl-copy,cliphisthas access to the original clipboard data type when storing clipboard history. Preserving this information avoids relying on heuristic MIME type detection during restoration and allows consumers such aswl-copyto use the original type information directly.