distrobox icon indicating copy to clipboard operation
distrobox copied to clipboard

[Error] Storing data into clipboard doesn't work in case of single shot command on Wayland

Open jkonecny12 opened this issue 3 years ago • 1 comments

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 test
  • distrobox enter test -- sudo dnf install -y wl-clipboard
  • distrobox enter test -- wl-copy 'abc'
  • check the clipboard

Working solution:

  • distrobox enter test
  • wl-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

jkonecny12 avatar Sep 08 '22 20:09 jkonecny12

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

89luca89 avatar Sep 21 '22 12:09 89luca89

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.

jkonecny12 avatar Sep 21 '22 21:09 jkonecny12

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:

89luca89 avatar Sep 22 '22 08:09 89luca89

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.

jkonecny12 avatar Oct 06 '22 10:10 jkonecny12

Not sure, never used sway to be honest, with gnome it works as intended :shrug:

89luca89 avatar Oct 06 '22 14:10 89luca89

Any news on this @jkonecny12 ? Seems to work well on gnome and kde wayland sessions from my testing

89luca89 avatar Oct 19 '22 17:10 89luca89

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.

jkonecny12 avatar Nov 15 '22 13:11 jkonecny12

Probably related to #432 and upstream related podman issue then

89luca89 avatar Nov 21 '22 22:11 89luca89

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.

jkonecny12 avatar Nov 28 '22 10:11 jkonecny12

Thanks a lot!

89luca89 avatar Nov 30 '22 07:11 89luca89