You are not logged in.
Hello there,
I don't really know what's going wrong because if I do something like
ls | wl-copy
then I can paste it with the normal keyboard shortcut everywhere.
What I'm trying to do, is write a message in an empty nvim buffer. Once I'm done typing my message I go to the top and do yG to copy the whole text. Then I do
:!wl-paste | gpg -u user -r recipient -ase | wl-copy
to encrypt my text and send it to the clipboard.
The issue is if I do CTRL+V or (CTRL+Shift+V in terminal) nothing appears. But if I run wl-paste my PGP message appears just fine. I tried wl-copy -p and it changed nothing. What am I doing wrong here?
Last edited by froli (2023-02-16 19:37:54)
archlinux on Macbook Pro 10,1
Offline
Neovim doesn't yank to the clipboard by default; you'd need to use the "+" register or set the "clipboard" to "unnamedplus". Did you do that?
Does your "wl-paste"/"wl-copy" pipe work outside of neovim?
Why do you even go through wl-paste to feed the buffer contents to gpg? Why not pipe the buffer to gpg directly with ":w !gpg […]"?
Offline
It's not a problem of neovim not yanking to the clipboard, I have that configured in my config. The issue is piping almost anything to wl-copy. I can pipe echo and ls and it's pretty much it. I don't know if there's something I don't understand about wl-copy or something.
And like I said, wl-copy actually does copy... it's just not "pastable". It only prints the stuffed I piped to it if I do wl-paste afterwards. But CTRL-V anywhere won't do anything. My compositor is hyprland by the way, in case that matters.
archlinux on Macbook Pro 10,1
Offline
It only prints the stuffed I piped to it if I do wl-paste afterwards. But CTRL-V anywhere won't do anything.
This contradicts your first example which you claim fails in which you try to use wl-paste to pipe to gpg.
FWIW Ctrl-V anywhere wont do anything for me either. This isn't Windows. What tool have you configured to bind Ctrl-V to some action? And what action is it bound to? Is that a hyprland default binding?
The issue is piping almost anything to wl-copy. I can pipe echo and ls and it's pretty much it...
And like I said, wl-copy actually does copy...
These also read as entirely contradictory.
Please clarify what the actual problem is and what observations led you to any of these inferences.
Last edited by Trilby (2023-02-16 17:37:33)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
This isn't Windows.
I wouldn't know. Didn't use Windows in 15 years aside for a web browser at work.
The issue is quite simple, I might just suck at explaining it.
When I pipe a command into wl-copy, sometimes I can paste the clipboard in other apps and sometimes I can't.
Let's say I run ls | wl-copy, then I have no issue pasting my clipboard anywhere I can input text. It pastes the output of the ls command right here in this post draft with CTRL-V or right click and paste.
But if I run my gpg command piped to wl-copy as such :
echo "some message" | gpg -u user -r recipient -ase | wl-copy
I won't be able to paste my clipboard anywhere. As if it's empty. But if I run wl-paste it does output my encrypted PGP message.
Does my explanation make any sense now?
archlinux on Macbook Pro 10,1
Offline
The pipe triggers this issue inside neovim as well as outside (say from a terminal)? If the latter can you set "$WAYLAND_DEBUG" to "1" and post the output of the pipe?
Does inserting a "sponge" step (comes from the "moreutils" package) before "wl-copy" change anything, i.e. "echo "some message" | gpg -u user -r recipient -ase | sponge | wl-copy"? Does the "-f" flag to wl-copy change anything, i.e. echo "some message" | gpg -u user -r recipient -ase | wl-copy -f"?
Last edited by 3beb6e7c46a615a (2023-02-16 18:03:38)
Offline
PS:
It's not a problem of neovim not yanking to the clipboard, I have that configured in my config.
This would've been helpful to include in the original post; after all we don't know your neovim configuration
Offline
PPS: I don't think the compositor matters; in wayland the compositor only negotiates the clipboard content type between applications, but the data itself gets passed directly from the pasting application to the target application. Technically, on copying the compositor asks the pasting application to write the clipboard data to a provided file descriptor, which the compositor then passes onwards to the target application to read from. Unlike X11 the clipboard data is never stored on the compositor/server. For this reason wl-copy forks a background process in order to supply the clipboard data to the paste application, and perhaps this is a bit racy when another non-trivial program like gpg is involved.
Offline
Let's say I run ls | wl-copy, then I have no issue pasting my clipboard anywhere I can input text. It pastes the output of the ls command right here in this post draft with CTRL-V or right click and paste.
But if I run my gpg command piped to wl-copy as such :
echo "some message" | gpg -u user -r recipient -ase | wl-copy
I won't be able to paste my clipboard anywhere. As if it's empty. But if I run wl-paste it does output my encrypted PGP message.
That makes much more sense, and I have a bit of a suspicion this might be an inferred content type issue. Does changing the pipe as follows change anything (as diagnostic not as solution):
echo "some message" | gpg -u user -r recipient -ase | cat | wl-copy
If that works, then using the -t flag for wl-copy would be a better long term approach (I like 'cat' here as a diagnostic as it is a more sure-fire check versus perhaps giving an incorrect mime type to the -t flag).
EDIT: oops, I suspect "sponge" would have the same effect here as cat ... though I don't really have experience with sponge.
A related test, though, is after piping into wl-copy, check the output of `wl-paste -l`.
Last edited by Trilby (2023-02-16 19:04:33)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
The pipe triggers this issue inside neovim as well as outside (say from a terminal)? If the latter can you set "$WAYLAND_DEBUG" to "1" and post the output of the pipe?
Does inserting a "sponge" step (comes from the "moreutils" package) before "wl-copy" change anything, i.e. "echo "some message" | gpg -u user -r recipient -ase | sponge | wl-copy"? Does the "-f" flag to wl-copy change anything, i.e. echo "some message" | gpg -u user -r recipient -ase | wl-copy -f"?
Yes the pipe triggers the issue regardless if it's used inside neovim or simply in the terminal. Sponge didn't help. Here's the output of my example command (without sponge) with WAYLAND_DEBUT=1:
[2940905.715] -> wl_display@1.get_registry(new id wl_registry@2)
[2940906.384] -> wl_display@1.sync(new id wl_callback@3)
[2940906.478] wl_display@1.delete_id(3)
[2940906.504] wl_registry@2.global(1, "wl_shm", 1)
[2940906.524] -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[2940906.542] wl_registry@2.global(2, "wl_drm", 2)
[2940906.559] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[2940906.575] wl_registry@2.global(4, "wl_compositor", 5)
[2940906.592] -> wl_registry@2.bind(4, "wl_compositor", 2, new id [unknown]@5)
[2940906.609] wl_registry@2.global(5, "wl_subcompositor", 1)
[2940906.625] wl_registry@2.global(6, "wl_data_device_manager", 3)
[2940906.643] -> wl_registry@2.bind(6, "wl_data_device_manager", 1, new id [unknown]@6)
[2940906.661] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[2940906.677] wl_registry@2.global(8, "zwlr_screencopy_manager_v1", 3)
[2940906.694] wl_registry@2.global(9, "zwlr_data_control_manager_v1", 2)
[2940906.710] -> wl_registry@2.bind(9, "zwlr_data_control_manager_v1", 2, new id [unknown]@7)
[2940906.727] wl_registry@2.global(10, "zwlr_gamma_control_manager_v1", 1)
[2940906.744] wl_registry@2.global(11, "zwp_primary_selection_device_manager_v1", 1)
[2940906.761] -> wl_registry@2.bind(11, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@8)
[2940906.778] wl_registry@2.global(12, "wp_viewporter", 1)
[2940906.794] wl_registry@2.global(13, "zwlr_output_power_manager_v1", 1)
[2940906.811] wl_registry@2.global(14, "xdg_wm_base", 5)
[2940906.827] -> wl_registry@2.bind(14, "xdg_wm_base", 1, new id [unknown]@9)
[2940906.844] wl_registry@2.global(15, "wl_seat", 8)
[2940906.860] -> wl_registry@2.bind(15, "wl_seat", 2, new id [unknown]@10)
[2940906.877] wl_registry@2.global(16, "wp_presentation", 1)
[2940906.893] wl_registry@2.global(17, "org_kde_kwin_idle", 1)
[2940906.909] wl_registry@2.global(18, "zwlr_layer_shell_v1", 4)
[2940906.925] wl_registry@2.global(19, "org_kde_kwin_server_decoration_manager", 1)
[2940906.942] wl_registry@2.global(20, "zxdg_decoration_manager_v1", 1)
[2940906.958] wl_registry@2.global(21, "zxdg_output_manager_v1", 3)
[2940906.974] wl_registry@2.global(22, "zwlr_output_manager_v1", 4)
[2940906.990] wl_registry@2.global(23, "zwlr_input_inhibit_manager_v1", 1)
[2940907.015] wl_registry@2.global(24, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[2940907.032] wl_registry@2.global(25, "zext_workspace_manager_v1", 1)
[2940907.048] wl_registry@2.global(26, "zwp_pointer_constraints_v1", 1)
[2940907.065] wl_registry@2.global(27, "zwp_relative_pointer_manager_v1", 1)
[2940907.081] wl_registry@2.global(28, "zwp_virtual_keyboard_manager_v1", 1)
[2940907.097] wl_registry@2.global(29, "zwlr_virtual_pointer_manager_v1", 2)
[2940907.113] wl_registry@2.global(30, "zwlr_foreign_toplevel_manager_v1", 3)
[2940907.129] wl_registry@2.global(31, "wp_drm_lease_device_v1", 1)
[2940907.145] wl_registry@2.global(32, "wp_drm_lease_device_v1", 1)
[2940907.161] wl_registry@2.global(33, "zwp_tablet_manager_v2", 1)
[2940907.177] wl_registry@2.global(34, "zwp_idle_inhibit_manager_v1", 1)
[2940907.193] wl_registry@2.global(35, "zxdg_exporter_v1", 1)
[2940907.209] wl_registry@2.global(36, "zxdg_importer_v1", 1)
[2940907.225] wl_registry@2.global(37, "zxdg_exporter_v2", 1)
[2940907.241] wl_registry@2.global(38, "zxdg_importer_v2", 1)
[2940907.257] wl_registry@2.global(39, "zwp_pointer_gestures_v1", 3)
[2940907.273] wl_registry@2.global(40, "zwp_text_input_manager_v3", 1)
[2940907.289] wl_registry@2.global(41, "zwp_input_method_manager_v2", 1)
[2940907.305] wl_registry@2.global(42, "xdg_activation_v1", 1)
[2940907.321] wl_registry@2.global(43, "xwayland_shell_v1", 1)
[2940907.336] wl_registry@2.global(44, "hyprland_toplevel_export_manager_v1", 2)
[2940907.352] wl_registry@2.global(45, "wp_fractional_scale_manager_v1", 1)
[2940907.368] wl_registry@2.global(46, "wl_output", 4)
[2940907.384] wl_callback@3.done(19493)
[2940907.401] -> wl_display@1.sync(new id wl_callback@3)
[2940907.463] wl_display@1.delete_id(3)
[2940907.484] wl_seat@10.name("seat0")
[2940907.501] wl_seat@10.capabilities(3)
[2940907.517] wl_callback@3.done(19493)
[2940907.534] -> zwlr_data_control_manager_v1@7.get_data_device(new id zwlr_data_control_device_v1@3, wl_seat@10)
[2941889.506] -> zwlr_data_control_manager_v1@7.create_data_source(new id zwlr_data_control_source_v1@11)
[2941889.615] -> zwlr_data_control_source_v1@11.offer("application/pgp-encrypted")
[2941889.671] -> zwlr_data_control_device_v1@3.set_selection(zwlr_data_control_source_v1@11)
[2941889.719] -> wl_display@1.sync(new id wl_callback@12)
[2941890.037] zwlr_data_control_source_v1@11.cancelled()
[2941890.337] wl_display@1.delete_id(12)
[2941890.361] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190080)
[2941890.380] zwlr_data_control_offer_v1@4278190080.offer("application/pgp-encrypted")
[2941890.394] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190080)
[2941890.407] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190081)
[2941890.418] zwlr_data_control_offer_v1@4278190081.offer("application/glfw+clipboard-3395")
[2941890.430] zwlr_data_control_offer_v1@4278190081.offer("TEXT")
[2941890.442] zwlr_data_control_offer_v1@4278190081.offer("STRING")
[2941890.452] zwlr_data_control_offer_v1@4278190081.offer("UTF8_STRING")
[2941890.463] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8")
[2941890.474] zwlr_data_control_offer_v1@4278190081.offer("text/plain")
[2941890.485] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190081)
[2941890.497] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190082)
[2941890.509] zwlr_data_control_offer_v1@4278190082.offer("application/pgp-encrypted")
[2941890.520] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190082)
[2941890.531] wl_callback@12.done(19495)
archlinux on Macbook Pro 10,1
Offline
I think the log confirms Trilby: The last lines suggest that wl-copy reports the "application/pgp-encrypted" mimetype for the copied data. I presume that's not something many applications understand and thus ignore the clipboard data when pasted to.
Try to explicitly force plain text with "wl-copy --type text/plain".
Last edited by 3beb6e7c46a615a (2023-02-16 19:13:55)
Offline
I think the log confirms Trilby: The last lines suggest that wl-copy reports the "application/pgp-encrypted" mimetype for the copied data. I presume that's not something many applications understand and thus ignore the clipboard data when pasted to.
Try to explicitly force plain text with "wl-copy --type text/plain".
Yep. That did the trick! It's the mimetype. Either app don't understand it or ignore it on purpose, I couldn't say but forcing it to text/plain solves it.
Thanks to both of you for the help!
archlinux on Macbook Pro 10,1
Offline