Skip to content
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 --type option ignored for text #222

Open
vadz opened this issue Apr 25, 2024 · 2 comments
Open

wl-copy --type option ignored for text #222

vadz opened this issue Apr 25, 2024 · 2 comments

Comments

@vadz
Copy link

vadz commented Apr 25, 2024

I'd like to put some text into clipboard in text/plain format only, i.e. without the TEXT, STRING and UTF8_STRING formats also used for it by default, but it seems that --type text/plain is ignored in this case and all the other types are still added:

$ wl-copy 'some text'
$ wl-paste -l        
text/plain
text/plain;charset=utf-8
TEXT
STRING
UTF8_STRING
$ wl-copy -t text/plain 'some other text'
$ wl-paste -l                      
text/plain
text/plain;charset=utf-8
TEXT
STRING
UTF8_STRING

This looks to be trivial to fix, as it would be enough to change the condition in this line

https://github.com/bugaevc/wl-clipboard/blame/4f20741f66c4e9bcf45481e941e344f8fe5e998d/src/wl-copy.c#L298

or just make it an else like this:

diff --git a/src/wl-copy.c b/src/wl-copy.c
index b040cb6..d71fc71 100644
--- a/src/wl-copy.c
+++ b/src/wl-copy.c
@@ -294,8 +294,7 @@ int main(int argc, argv_t argv) {
         copy_action->source = device_manager_create_source(device_manager);
         if (options.mime_type != NULL) {
             source_offer(copy_action->source, options.mime_type);
-        }
-        if (options.mime_type == NULL || mime_type_is_text(options.mime_type)) {
+        } else if (mime_type_is_text(options.mime_type)) {
             /* Offer a few generic plain text formats */
             source_offer(copy_action->source, text_plain);
             source_offer(copy_action->source, text_plain_utf8);

but I don't make a PR for this as I'm not sure if this is not intentional. If you'd like one, please let me know.

@bugaevc
Copy link
Owner

bugaevc commented Apr 25, 2024

Hi, this was very intentional. As you note, --type is not ignored, but we additionally offer generic text formats if the type you specify with --type looks textual; without this, many clients will refuse to paste your data.

Why is this an issue for you / what are you actually trying to achieve?

@vadz
Copy link
Author

vadz commented Apr 25, 2024

Hi, this was very intentional. As you note, --type is not ignored, but we additionally offer generic text formats if the type you specify with --type looks textual; without this, many clients will refuse to paste your data.

I see, thanks. Maybe there could be some --force-type option to still do what I want? But it's probably too niche...

Why is this an issue for you / what are you actually trying to achieve?

I'm testing one of such broken clients :-) and I need to be able to put text on clipboard without providing it as [UTF8_]STRING to trigger the bug. It can be done manually by copying text from Nautilus but wl-copy is just so much more convenient to use (thanks a lot for this great tool, BTW!). And I was also thinking of adding a non-interactive test checking that pasting text in any format works and for this I could only use wl-copy.

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

No branches or pull requests

2 participants