Skip to content

Conversation

@Vaisakhkm2625
Copy link

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

use | as a delimiter to split mimetypes in -t option
eg:
```c
> 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
```
@septatrix
Copy link

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

@Vaisakhkm2625
Copy link
Author

Vaisakhkm2625 commented Feb 7, 2025

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

@septatrix
Copy link

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.

@Vaisakhkm2625
Copy link
Author

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

execlp("xdg-mime", "xdg-mime", "query", "filetype", file_path, NULL);

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

@septatrix
Copy link

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
Copy link

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.

@bugaevc
Copy link
Owner

bugaevc commented Feb 8, 2025

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.

@Vaisakhkm2625
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants