[Error] Storing data into clipboard doesn't work in case of single shot command on Wayland
Describe the bug
If you run distrobox enter and copy something into clipboard then everything works great. However, if you do the same with distrobox enter -- wl-copy 'abc' then the clipboard is empty.
The same behavior is also on toolbx run. I don't know if it's podman specific or something else.
I found this issue thanks to the export of gopass but the same issue seems to be with pass. Both of these works great inside the container shell but when you use arguments to copy the value without entering shell in the container the clipboard is empty.
To Reproduce On a Wayland system:
distrobox create --image registry.fedoraproject.org/fedora-toolbox:36 --name testdistrobox enter test -- sudo dnf install -y wl-clipboarddistrobox enter test -- wl-copy 'abc'- check the clipboard
Working solution:
distrobox enter testwl-copy 'abc'- check the clipboard
Expected behavior
There should be no difference between enter wl-copy 'abc' and enter; wl-copy 'abc'.
Logs verbose.log
Desktop (please complete the following information):
-
Are you using podman or docker? podman
-
Which version or podman or docker?
❯ podman --version
podman version 4.2.0
- Which version of distrobox?
❯ distrobox --version
distrobox: 1.3.1
Hi @jkonecny12
just to test, can you see if running
distrobox enter test -- "wl-copy 'abc' && sleep 1s"
Just to see if maybe the main process is exiting too fast for wl-copy to finish what it needs to do
Hi, tested and unfortunately no, it doesn't change the result. Still the clipboard is empty.
One more note:
When I have something in the clipboard already and run wl-copy "abc" in the distrobox the clipboard is erased (it's empty) after the call. So something is happening with the clipboard but for some reason the new text is not stored.
mmmh I see a problem here, was trying to reproduce, but I cannot:
distrobox create --image registry.fedoraproject.org/fedora-toolbox:36 --name test
distrobox enter test -- sudo dnf install -y wl-clipboard
distrobox enter test -- wl-copy 'abc'
Works for me, I've even tried mapping it to a custom shortcut (using gnome settings) and it worked :thinking:
Thank you for testing this. Interesting. Could it be a host issue?
I'm running Sway which is Wayland - maybe there is the catch? I can try to check a different environment.
Not sure, never used sway to be honest, with gnome it works as intended :shrug:
Any news on this @jkonecny12 ? Seems to work well on gnome and kde wayland sessions from my testing
I tested SilverBlue and it works as expected but for some reason it doesn't work so well on Sway.
It works on sway if I do:
distrobox enter test -- wl-copy --foreground --paste-once 'abc'
I guess the issue is that the wl-copy fork is closed when the foreground command is finished. This works but it will block the execution and also doesn't help with applications using clipboard.
Probably related to #432 and upstream related podman issue then
Hi, sorry for late reply but we can close this.
I tried to find out more and discovered that this is a correct behavior. Wayland as protocol (and as implemented in Sway) does not have a persistent clipboard but instead it just sending data between applications. So if you don't have a clipboard manager (which KDE and Gnome probably have) you have to have the source application running or the clipboard is empty.
In this case distrobox will close the connection before I'm able to use the clipboard. I should be able to solve this by using a clipboard manager.
Thanks for your help and sorry for taking your time. Feel free to close this issue.
Thanks a lot!