Feat multiple mime types support
Added multi mime type input support for -t option
use | as a delimiter to split mimetypes in -t option
eg:
> wl-copy -t "x-special/gnome-copied-files|text/uri-list"
file:///home/user/Videos/getvid.mp4
> wl-paste --list-types
x-special/gnome-copied-files
text/uri-list
As said in https://github.com/bugaevc/wl-clipboard/issues/244#issuecomment-2642883885 this still does not help with application/vnd.portal.filetransfer which requires special handling. Additionally this code should also automatically infer multiple types if piped in from a file which I think it currently does not
As said in #244 (comment) this still does not help with
application/vnd.portal.filetransferwhich requires special handling. Additionally this code should also automatically infer multiple types if piped in from a file which I think it currently does not
This PR is not for adding support for individual mime-types/protocols, which there are of 700+ https://mimetype.io/all-types
this adds supports for specifying multiple mimetypes for the flag '-t' which overrides the default mime types which is 'text'
also for specifically application/vnd.portal.filetransfer , i don't think that won't even comes under this project, even if, it takes a major effort to get done
As said in #244 (comment) this still does not help with
application/vnd.portal.filetransferwhich requires special handling. Additionally this code should also automatically infer multiple types if piped in from a file which I think it currently does notThis PR is not for adding support for individual mime-types/protocols, which there are of 700+ https://mimetype.io/all-types
I mean when using wl-copy <foobar.pdf which already correctly results in wl-paste --list-types reporting application/pdf. It would be great if it would now also automatically add text/uri-list etc.
As said in #244 (comment) this still does not help with
application/vnd.portal.filetransferwhich requires special handling. Additionally this code should also automatically infer multiple types if piped in from a file which I think it currently does notThis PR is not for adding support for individual mime-types/protocols, which there are of 700+ https://mimetype.io/all-types
I mean when using
wl-copy <foobar.pdfwhich already correctly results inwl-paste --list-typesreportingapplication/pdf. It would be great if it would now also automatically addtext/uri-listetc.
it's not something handled directly by wl-copy, it's just result of your system's xdg-mime settings
https://github.com/bugaevc/wl-clipboard/blob/4f20741f66c4e9bcf45481e941e344f8fe5e998d/src/util/files.c#L173
run
❯ xdg-mime query filetype app.pdf
application/pdf
identifying and adding mime type to files is a herculean project on it's own (even xdg-mime type spec can't keep up ), so at-least currently i have no idea how to do it manually,
and hard coding text/uri-list is not a good idea, as it's a std uri spec for browsers, which might def cause unforeseen issues where apps trying to handle texts like file system paths...
currently wl-copy uses filename (based on /etc/mime.types), descriptor, and xdg-mime type to detect. so except for text, i don't think it's worth hard coding everything.
anyway, it't won't comes under this pr
use
|as a delimiter to split mimetypes in -t option
Hm | is technically allowed as part of a mimetype according to RFC2045 Section 5.1. A , at least is specified to require quote escaping when used within a mimetype so we could detect that. However, I think the easier path is to just allow -t to be specified multiple times on the command line.
I mean when using
wl-copy <foobar.pdfwhich already correctly results inwl-paste --list-typesreportingapplication/pdf. It would be great if it would now also automatically addtext/uri-listetc.it's not something handled directly by
wl-copy, it's just result of your system's xdg-mime settings[...]
identifying and adding mime type to files is a herculean project on it's own (even xdg-mime type spec can't keep up ), so at-least currently i have no idea how to do it manually, and hard coding
text/uri-listis not a good idea, as it's a std uri spec for browsers, which might def cause unforeseen issues where apps trying to handle texts like file system paths...
I was not advocating for manual detection, sorry if I was being unclear. My suggestion was only about automatically setting text/uri-list etc when copying a file. However I did not know that there are apps where this causes trouble.
Hi, so this looks like it would always produce the exact same content no matter which data type gets requested? Please see https://github.com/bugaevc/wl-clipboard/issues/71 for some context.
Hi, so this looks like it would always produce the exact same content no matter which data type gets requested? Please see #71 for some context. yes, this is for overriding existing datatypes with -t flag...
i am looking this for specifically for making yazi and other terminal file managers work with gui file managers and brower.. so if detection with -t not working, we can override it in script/plugins used in these file mangers..
if not a good idea, we can close this commit...