wl-clipboard icon indicating copy to clipboard operation
wl-clipboard copied to clipboard

Feat multiple mime types support

Open Vaisakhkm2625 opened this issue 11 months ago • 8 comments

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

Vaisakhkm2625 avatar Feb 07 '25 12:02 Vaisakhkm2625

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

septatrix avatar Feb 07 '25 13:02 septatrix

As said in #244 (comment) 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

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

Vaisakhkm2625 avatar Feb 07 '25 14:02 Vaisakhkm2625

As said in #244 (comment) 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

This 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.

septatrix avatar Feb 07 '25 14:02 septatrix

As said in #244 (comment) 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

This 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.

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

Vaisakhkm2625 avatar Feb 07 '25 18:02 Vaisakhkm2625

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.

septatrix avatar Feb 07 '25 19:02 septatrix

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.

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-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...

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.

septatrix avatar Feb 07 '25 19:02 septatrix

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.

bugaevc avatar Feb 08 '25 20:02 bugaevc

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...

Vaisakhkm2625 avatar Feb 11 '25 08:02 Vaisakhkm2625