wl-clipboard
wl-clipboard copied to clipboard
wl-copy `--type` option ignored for text
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.
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?
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.