Command line application copy paste issues

Hey!
I am maintaining a command line python application currently packaged as a snap that need to write to the clipboard so that the user then can paste the result.

The python application is using pyperclip for the interaction with the clipboard for increased portability.

When running the application as a snap on the Librem 5, I get no error but also nothing in the clipboard to paste.

Trying out pyperclip in an python3 venv on the librem 5, pyperclip throws an exception telling me it cannot find a copy paste mechanism.

So… Ideas on what to try to get the snap copy pasting again? Or is this likely a pure os snap integration issue and if so where should I report that?

Pyperclip docs say it uses either xsel or xclip on the backend, neither of which is pre-installed on the Librem 5. Those, in turn, seem to make use of the X11 windowing system, whereas the Librem 5 uses Wayland by default. However, looking at the code for pyperclip, it seems like it should also be able to make use of wl-clipboard for Wayland sessions. This is also not pre-installed on the Librem 5, though.

Try sudo apt install wl-clipboard, then trying again.

2 Likes

Thanks for the suggestion, this would not be the first time wayland/x11 differences have caused my application copy paste issues.

After installing wl-clipboard the snap still does not write to the clipboard. The ā€œregularā€ python script just running in a venv no longer complaints but still nothing showing up in the clipboard. Also tested using wl-copy directly without any results. Calling wl-paste works and happily pastes the most recent thing before I tried to run any of my scripts.

I would not be surprised if it is wayland related… But it something more is in the works. This all works on opensuse Tumbleweed using a GNOME desktop running on wayland.

I am not so sure then. It might be some difference between phosh and GNOME then (since the Librem 5 is not quite running a pure GNOME desktop).

Maybe @dcz can answer

I actually don’t know how clipboard works on Wayland.

Ah, ok, I thought I remembered that you had worked on copy/paste mechanisms with the L5. Perhaps I am mistaken.

@emiljoha If no one manages to resolve things here, you could try joining some of the Matrix chat rooms.

#community-librem-5:talk.puri.sm
#community-librem-apps:talk.puri.sm

Thanks @wctaylor for your help!

Will see if someone have any ideas in the matrix chats. Clipboards are harder than they seem…

Update: I got some help in the #community-librem-5:talk.puri.sm where they suggested I compile the latest version of wl-clipboard from github https://github.com/bugaevc/wl-clipboard

With the newer version of wl-clipboard both wl-copy and pyperclip started to work :partying_face:

However, the snap still does not write to the clipboard.

I don’t know much about Snaps, but

  1. Is the snap being built with the freshly-compiled version of wl-clipboard?
  2. Is there some permissions issue? Like, do you have to specifically allow clipboard access from the snap somehow?

Is the snap being built with the freshly-compiled version of wl-clipboard ?

That is a good idea! Will try that.

Is there some permissions issue? Like, do you have to specifically allow clipboard access from the snap somehow?

There have been a lot of that type of issues but I those times pyperclip have thrown an exception warning me. So I am living on the hope that using the latest wl-clipboard will help.

Eventually went with going flatpak route.

Did not manage to sort out updating the snap wl-clipboard but very likley the snap is suffering from the old version as well. Using 2.0 in the flatpak works like a charm as long as I give it wayland priviliges. :partying_face:

Thanks for all the help @wctaylor !

1 Like