13

Is there a Wayland cli utility that copies text to clipboard?

I want to be able to do something like this:

echo "some" > clipboard

Something equivalent to xclip.

  • 1
    I'd be really interested to see the answer to this question too. From my usage of gnome-wayland, it seems to have many restrictions on clipboard access. For example, if you copy something in program A and you close it, the clipboard will automatically get flushed. There is no restriction on copy to clipboard for xclip but it seems pasting will only work if you've copied something while in terminal but not anywhere else. on the other hand, ctrl-v/shift-ctrl-v has no restriction as long as original app is opened... – thebunnyrules Feb 22 '18 at 6:22
  • Discussion regarding wayland + clipboard - wiki.gnome.org/Initiatives/Wayland/PrimarySelection. According to this ticket it sounds like it's been implemented - github.com/swaywm/sway/issues/1012. – slm Jun 12 '18 at 2:38
  • thanks for the links however that did not help me. maybe i missed something – mh-cbon Jun 12 '18 at 17:14
5

bugaevc's wl-clipboard are copy/paste utilities for Wayland:

This project implements two little Wayland clipboard utilities, wl-copy and wl-paste, that let you easily copy data between the clipboard and Unix pipes, sockets, files and so on.

Usage is as simple as:

# copy a simple text message
$ wl-copy Hello world!

# copy the list of files in Downloads
$ ls ~/Downloads | wl-copy

# copy an image file
$ wl-copy < ~/Pictures/photo.png

# paste to a file
$ wl-paste > clipboard.txt

# grep each pasted word in file source.c
$ for word in $(wl-paste); do grep $word source.c; done

# copy the previous command
$ wl-copy "!!"

# replace the current selection with the list of types it's offered in
$ wl-paste --list-types | wl-copy

Although wl-copy and wl-paste are particularly optimized for plain text and other textual content formats, they fully support content of arbitrary MIME types. wl-copy automatically infers the type of the copied content by running xdg-mime(1) on it. wl-paste tries its best to pick a type to paste based on the list of offered MIME types and the extension of the file it's pasting into. If you're not satisfied with the type they pick or don't want to rely on this implicit type inference, you can explicitly specify the type to use with the --type option.

  • looks really cool! but i met with src/meson.build:1:0: ERROR: Dependency "wayland-client" not found, tried pkgconfig and cmake during install. I m sure its a stupid mistake from me. is it ? I have run sudo dnf i meson -y prior to the build attempt. – mh-cbon 12 hours ago
2

wclip is a clipboard tool for Wayland that is very similar to xclip.

Usage is as follows:

$ wclip i < my_text_file

$ wclip o contents of my text file $

Disclaimer: I am the author.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.