bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.62k stars 59 forks source link

Copying from stdin not working #55

Closed FunctionalHacker closed 5 years ago

FunctionalHacker commented 5 years ago

Trying to copy with the following command is not working: echo "test" | wl-copy

My specs: Arch Linux wl-clipboard r133.c010972-1 sway 1.2-2 wlroots 0.7.0-1 alacritty 0.3.3-3

EDIT: Fixed wl-clipboard version

bugaevc commented 5 years ago

Thanks for the report!

How exactly it is "not working"? Does it crash? Print an error message? Are you unable to paste it afterwards? How (and where to) are you trying to paste it — with wl-paste? into a native Wayland app? into an XWayland app?

wl-clipboard r80.48c2aed-1

This appears to be a reference to the wl-clipboard 1.0 release commit. The 1.0 release is pretty old by this point (hopefully, there'll be a 2.0 release soon!), so it's possible that your bug has already been fixed, so please try if it works on master.

FunctionalHacker commented 5 years ago

Sorry the version is actually r133.c010972-1, shouldn't create issues early in the morning :smile:

To clarify, the issue I'm having is pasting with the shortcut keys back to alacritty, nothing is pasted when I do C-shift-v. Firefox gets asian characters when I try to paste in the address bar. Both are running in wayland native mode.

If I do wl-copy "test" instead it works perfectly both in alacritty and firefox. Let me know if you want to test anything else.

Oh and my shell is zsh if that makes a difference

EDIT: wl-paste works in both cases (stdin or as an argument to wl-copy). No error messages are printed in any of these cases.

bugaevc commented 5 years ago

Sorry the version is actually r133.c010972-1, shouldn't create issues early in the morning smile

So, the it's the latest master then! Good.

What does wl-paste --list-types say after you do the copy?

What does echo test | WAYLAND_DEBUG=1 wl-copy --foreground say? (initially when you copy, and after you try to paste into say alacritty? after you try to paste with wl-paste?)

FunctionalHacker commented 5 years ago
❯ echo test | wl-copy && wl-paste --list-types
/tmp/wl-copy-buffer-jWFvlY/stdin
  text/plain

The --foreground switch just makes wl-clipboard hang indefinitely. I tried echo test | WAYLABD_DEBUG=1 wl-copy also but I don't get any output

bugaevc commented 5 years ago

/tmp/wl-copy-buffer-jWFvlY/stdin

Is this an output of wl-paste --list-types?

The --foreground switch just makes wl-clipboard hang indefinitely

Until you copy something else, this is. You don't actually need it to for this test, but it's more convenient if it stays in foreground.

WAYLABD_DEBUG=1

That was my typo that I've already corrected in my message above :smile: please test again with the correct name.

FunctionalHacker commented 5 years ago

/tmp/wl-copy-buffer-jWFvlY/stdin

Is this an output of wl-paste --list-types?

Correct.

Okay now I get some output with echo test | WAYLAND_DEBUG=1 wl-copy --foreground:

[2243832.862]  -> wl_display@1.get_registry(new id wl_registry@2)
[2243832.904]  -> wl_display@1.sync(new id wl_callback@3)
[2243834.766] wl_display@1.delete_id(3)
[2243834.821] wl_registry@2.global(1, "wl_shm", 1)
[2243834.839]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[2243834.890] wl_registry@2.global(2, "zwp_linux_dmabuf_v1", 3)
[2243834.909] wl_registry@2.global(3, "wl_drm", 2)
[2243834.933] wl_registry@2.global(4, "wl_compositor", 4)
[2243834.974]  -> wl_registry@2.bind(4, "wl_compositor", 3, new id [unknown]@5)
[2243835.003] wl_registry@2.global(5, "wl_subcompositor", 1)
[2243835.025] wl_registry@2.global(6, "wl_data_device_manager", 3)
[2243835.040]  -> wl_registry@2.bind(6, "wl_data_device_manager", 1, new id [unknown]@6)
[2243835.115] wl_registry@2.global(7, "zwlr_gamma_control_manager_v1", 1)
[2243835.139] wl_registry@2.global(8, "gtk_primary_selection_device_manager", 1)
[2243835.160]  -> wl_registry@2.bind(8, "gtk_primary_selection_device_manager", 1, new id [unknown]@7)
[2243835.189] wl_registry@2.global(9, "zxdg_output_manager_v1", 3)
[2243835.208] wl_registry@2.global(10, "org_kde_kwin_idle", 1)
[2243835.233] wl_registry@2.global(11, "zwp_idle_inhibit_manager_v1", 1)
[2243835.257] wl_registry@2.global(12, "zwlr_layer_shell_v1", 1)
[2243835.274]  -> wl_registry@2.bind(12, "zwlr_layer_shell_v1", 1, new id [unknown]@8)
[2243835.292] wl_registry@2.global(13, "zxdg_shell_v6", 1)
[2243835.308] wl_registry@2.global(14, "xdg_wm_base", 2)
[2243835.327]  -> wl_registry@2.bind(14, "xdg_wm_base", 1, new id [unknown]@9)
[2243835.349] wl_registry@2.global(15, "org_kde_kwin_server_decoration_manager", 1)
[2243835.368] wl_registry@2.global(16, "zxdg_decoration_manager_v1", 1)
[2243835.394] wl_registry@2.global(17, "zwp_relative_pointer_manager_v1", 1)
[2243835.422] wl_registry@2.global(18, "zwp_pointer_constraints_v1", 1)
[2243835.446] wl_registry@2.global(19, "wp_presentation", 1)
[2243835.459] wl_registry@2.global(20, "zwlr_output_manager_v1", 1)
[2243835.475] wl_registry@2.global(21, "zwlr_export_dmabuf_manager_v1", 1)
[2243835.489] wl_registry@2.global(22, "zwlr_screencopy_manager_v1", 1)
[2243835.505] wl_registry@2.global(23, "zwlr_data_control_manager_v1", 2)
[2243835.519]  -> wl_registry@2.bind(23, "zwlr_data_control_manager_v1", 1, new id [unknown]@10)
[2243835.545] wl_registry@2.global(24, "zwp_primary_selection_device_manager_v1", 1)
[2243835.574]  -> wl_registry@2.bind(24, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@11)
[2243835.595] wl_registry@2.global(25, "zwp_virtual_keyboard_manager_v1", 1)
[2243835.612] wl_registry@2.global(26, "zwlr_input_inhibit_manager_v1", 1)
[2243835.629] wl_registry@2.global(27, "wl_seat", 7)
[2243835.653]  -> wl_registry@2.bind(27, "wl_seat", 2, new id [unknown]@12)
[2243835.681] wl_registry@2.global(28, "wl_output", 3)
[2243835.712] wl_callback@3.done(7654)
[2243835.722]  -> wl_data_device_manager@6.get_data_device(new id wl_data_device@3, wl_seat@12)
[2243835.742]  -> gtk_primary_selection_device_manager@7.get_device(new id gtk_primary_selection_device@13, wl_seat@12)
[2243835.767]  -> zwp_primary_selection_device_manager_v1@11.get_device(new id zwp_primary_selection_device_v1@14, wl_seat@12)
[2243835.786]  -> zwlr_data_control_manager_v1@10.get_data_device(new id zwlr_data_control_device_v1@15, wl_seat@12)
[2244068.196]  -> zwlr_data_control_manager_v1@10.create_data_source(new id zwlr_data_control_source_v1@16)
[2244068.246]  -> zwlr_data_control_source_v1@16.offer("/tmp/wl-copy-buffer-gBhSU5/stdin
  text/plain")
[2244068.256]  -> zwlr_data_control_device_v1@15.set_selection(zwlr_data_control_source_v1@16)
[2244068.520] wl_seat@12.name("seat0")
[2244068.544] wl_seat@12.capabilities(7)
[2244068.554]  -> wl_seat@12.get_keyboard(new id wl_keyboard@17)
[2244068.836] wl_keyboard@17.keymap(1, fd 4, 50255)
bugaevc commented 5 years ago

Aha.

What does xdg-mime query filetype /path/to/some/text/file output for you? It's supposed to output just text/plain. If it outputs

/path/to/some/text/file
 text/plain

then it's a bug in xdg-mime. If it does output text/plain correctly, it might be a bug in how wl-clipboard is parsing its output.

FunctionalHacker commented 5 years ago

Yeah it outputs the path as well. Is this something I should report to the developers of xdg-mime?

FunctionalHacker commented 5 years ago

Oh I think I found the reason! I use mimeo and xdg-utils-mimeo, which makes all programs use mimeo. When I install xdg-utils, everything works as expected.

I would really like to continue using mimeo though. Should I contact the developer of mimeo to see if we can work this out?

bugaevc commented 5 years ago

Sounds like it's a bug in either one of those packages then, yes, so you should contact their developers.

I'm closing this issue, but feel free to reopen it if anything turns up.

FunctionalHacker commented 5 years ago

Alright thanks for your help!

FunctionalHacker commented 5 years ago

Just to let you (or anyone else with the same issue), I reported the fix and the latest xdg-utils-mimeo is working with wl-clipboard now :)