10

Is there such a thing as a clipboard API in Wayland? Or where should I look to paste contents to the clipboard programmatically?

I am running Fedora 24 on Wayland.

Having a single clipboard if perfectly fine with me, so is there a code example (in Python, etc.)?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
anatoly techtonik
  • 17,421
  • 8
  • 111
  • 131

3 Answers3

9

In Linux we have two 'clipboards'. Primary selection and clipboard.

Clipboard is defined by the Wayland protocol here: https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-data-sharing

The primary selection is unwanted in Wayland, because it is considered unsecure. But to smooth the move from X to Wayland, an extension, disabled by default, has been created: https://wiki.gnome.org/Initiatives/Wayland/PrimarySelection

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
alkino
  • 468
  • 4
  • 11
  • Thanks. Updated question that there is no need in backward compatibility. – anatoly techtonik Oct 15 '16 at 17:25
  • 7
    Being "unwanted" is arguable. It's a major usability feature for working with mouse, and there are ways to make it safer. Last time I saw there was a decision on #wayland channel about including it into libweston. Nothing beyond a talk so far though. – Hi-Angel Aug 07 '17 at 09:45
2

Manipulating the clipboard on Wayland usually requires a valid serial for an input event. Some compositors validate this serial (Weston), some don't (Kwin). So it might be that you can't do what you want.

As mentioned by alkino, there are docs here: https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-data-sharing

And here: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_data_device

bobbaluba
  • 2,812
  • 2
  • 27
  • 38
2

wl-clipboard provides wl-copy and wl-paste which you can script easily.

Tim Morgan
  • 1,084
  • 8
  • 12