New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wl-copy: how to craft a multi-mimetype copy #71
Comments
There's (currently) no way to do this; there is always a single input If you copy something wl-clipboard believes to be text, it'll also automatically offer Lines 252 to 259 in c983120
but will serve the same content. See #8 for an early plan to generate different versions automatically (I'm still not sure that's a good idea). It would be possible to let the user specify several source/type pairs, but
but at this point it's better to start using Wayland directly instead of spawning Let's make an experiment. There already is a private libwl-clipboard in wl-clipboard 2.0; it's not public or stable, the API will change and so on, but it's fine for an experiment. Can you try using it (via cgo, probably) and see if it's convenient enough for you? |
For the command line, maybe something like I'll look into the library and see if I can understand it (I don't know any C or low-level stuff). |
There is a valid use case for being able to set multiple mime types for the data that is copied. For example, when you copy an image from a browser,
While if you take a screenshot with About the syntax for the flag, how about just a simple comma separate strings for adding multiple types to the data:
|
(Quick note: the exact list is of course browser-specific, your seems to come from Firefox)
This sounds like a bug in the browser (or even the webpage) you're experiencing this with. Besides, why do you think it is specifically the lack of MIME types other than That is not to say that it's a bad idea to want to be able to copy multiple types into the clipboard...
Where would that take the data from? In particular, what would the HTML data be when copying an image? With a single type (here, |
Yes, it comes from Firefox when copying an image. Pasting the image from the browser trigger file upload and it works as expected. It's only when the image coming from wl-copy that it cannot be detected properly. The suggestion is just to extends what is currently supported with the |
You should report this issue to Firefox.
So you're saying you would want
|
The issue is not because of Firefox though. For example, copying image from Gimp gives these mime types:
and pasting this in the browser also works as expected. In this case the image formats are also interchangeable like the text formats. |
How is this relevant? No matter what GIMP is able to copy, Firefox should be able to paste
No. Why would you think so? $ wl-paste -t image/png | sha256sum
ac2aac0023c36c8811f435077c3d76449c1c9b05cb980ea2b058ed24638a7e03 -
$ wl-paste -t image/jpeg | sha256sum
ce0e689283d419d4c6c3014e17eb64f7c692b23416b1650a0545d8d9dfbcf5bc -
$ wl-paste -t image/bmp | sha256sum
dca2e36091578012d28acead8d5c08af678b73d86f2dcc842269ad93a0b95b40 - |
Please don't focus on Firefox too much as the behavior is website specific and not because of the browser. It behaves the same way in Chromium too. Here is the mime types for an image copied in Chromium for example:
I haven't investigated the combination of the mime types which makes it behave correctly yet though, but only want to suggest that wl-copy could support multi-mimetype like other applications. With your example, these text mime types also differs?
Note that unicode chars would not make the content identical if the mime type differ. I guess this also applies for images and it's the receiving application who accepts in which of the offered mime types it want to receive the data. |
Well in any case, it's something between the browser and the website that's broken if you cannot just paste a PNG image. Maybe the browser should synthesize the types that the known to be broken websites can't live without. Providing the same image binary as Again, making it possible to copy multiple content types could be a somewhat useful feature — for copying rich text, mostly, but not for working around broken clients that cannot handle simple images.
You realize your shell parses this as $ wl-paste -t text/plain
$ charset=utf-8 right? You need to quote the |
Could it be that the other applications are setting multiple data parts with different mime types when the user is copying an image into the clipboard? For example, here is a list of mime types that a web application inspect using the browser's clipboard API https://w3c.github.io/clipboard-apis/#mandatory-data-types-x Does Yeah, sorry about the mistake in the commands, I realized it after a while. It does return the same data:
|
What format does Confluence natively copy/paste its contents in? Does |
So your issue seems to be that |
Hi. But if I want to copy something with wl-copy(rich text from Writer or html from firefox) and store it with all mimetypes in set of files(or sqlite tables with mimetypes) how I can write all data with all mimetimes to clipboard later? With proposed feature(with crafting a multi-mimetype copy) it would be possible. But without this feature it can't be possible. |
I have two cases when I want to copy as multiple types.
|
I have a proposal for supporting multi-mimetype copy without temporary files, using an external converter program: wl-copy keeps taking a single buffer from stdin of a specific type (autodetected or These converters can be very simple adapters to existing tools. They help to keep the A simple image converter
Then, a user could call This would solve the use cases in the last comment with reasonable complexity in wl-copy, flexible and easy to use, much easier than using a library to access the wayland clipboard. Different pre-existing types (so no on-demand conversion) are not the primary use case, but it still can be done by piping an archive to wl-copy that contains a file per type and use this converter program: |
wl-paste allows me to pick between several mime types, as offered by the source application.
I'm having a hard time understanding how I can offer several mime types at the same time using wl-copy, for example
text/html
andtext/plain
with different contents.The text was updated successfully, but these errors were encountered: