wl-copy Man Page - Linux
Copy to clipboard (wayland).
Syntax
wl-copy [--primary] [--type mime/type] [text...]
wl-copy Copy the given text to the Wayland clipboard. If no text is given, copy data from standard input.
wl-paste Paste data from the Wayland clipboard to standard output.
Options
-c, --clear
Instead of copying anything, clear the clipboard so that nothing is copied.
-f, --foreground
By default, wl-copy forks and serves data requests in the background; this option overrides that
behavior, causing wl-copy to run in the foreground.
-n, --trim-newline
Do not copy the trailing newline character if it is present in the input file.
-o, --paste-once
Only serve one paste request and then exit. Unless a clipboard manager specifically designed to
prevent this is in use, this has the effect of clearing the clipboard after the first paste, which
is useful for copying sensitive data such as passwords. Note that this may break pasting into some
clients that expect to be able to paste multiple times, in particular pasting into XWayland
windows is known to break when this option is used.
-p, --primary
Use the "primary" clipboard instead of the regular clipboard.
-s seat-name, --seat seat-name
Specify which seat wl-copy and wl-paste should work with. Wayland natively supports multi-seat
configurations where each seat gets its own mouse pointer, keyboard focus, and among other things
its own separate clipboard. The name of the default seat is likely default or seat0, and
additional seat names normally come from the udev(7) property ENV{WL_SEAT}. You can view the list
of the currently available seats as advertised by the compositor using the weston-info(1) tool. If
you don't specify the seat name explicitly, wl-copy and wl-paste will pick a seat arbitrarily. If
you are using a single-seat system, there is little reason to use this option.
-t mime/type, --type mime/type
Override the automatically selected MIME type.
For wl-copy this option controls which type wl-copy will offer the content as.
-h, --help
Display a short help message listing the available options.
-v, --version
Display the version of wl-clipboard and some short info about its license.
Unless the Wayland compositor implements the wlroots data-control protocol, wl-clipboard has to resort to using a hack to access the clipboard: it will briefly pop up a tiny transparent surface (window). On some desktop environments (in particular when using tiling window managers), this can cause visual issues such as brief flashing. In some cases the Wayland compositor doesn't give focus to the popup surface, which prevents wl-clipboard from accessing the clipboard and manifests as a hang.
There is currently no way to copy data in multiple MIME types, such as multiple image formats, at the same time.
See https://github.com/bugaevc/wl-clipboard/issues/71 (2019).
wl-clipboard is not always able to detect that a MIME type is textual, which may break pasting into clients that expect textual formats, not application/something. The workaround, same as for all format inference issues, is to specify the desired MIME type explicitly, such as wl-copy --type text/plain. wl-copy --clear and wl-copy --paste-once don't always interact well with clipboard managers that are overeager to preserve clipboard contents.
Applications written using the GTK 3 toolkit copy text with "\r\n" (also known as CR LF) line endings, which takes most other software by surprise. wl-cipboard does nothing to rectify this. The recommended workaround is piping wl-paste output through dos2unix(1) when pasting from a GTK 3 application. See <https://gitlab.gnome.org/GNOME/gtk/-/issues/2307>.
When trying to paste content copied with wl-copy, wl-copy does not check whether the requested MIME type is among those it has offered, and always provides the same data in response.
Install for Wayland
# Install using your package manager: apt-get install wl-clipboard or pacman -S wl-clipboard or dnf install wl-clipboard
Environment
WAYLAND_DISPLAY
Specifies what Wayland server wl-copy and wl-paste should connect to. This is the same environment
variable that you pass to other Wayland clients, such as graphical applications, that connect to
this Wayland server. It is normally set up automatically by the graphical session and the Wayland
compositor. See wl_display_connect(3) for more details.
WAYLAND_DEBUG
When set to 1, causes the wayland-client(7) library to log every interaction wl-copy and wl-paste
make with the Wayland compositor to stderr.
CLIPBOARD_STATE
Set by wl-paste for the spawned command in --watch mode. Currently the following possible values
are defined:
CLIPBOARD_STATE=data
Indicates that the clipboard contains data that the spawned command can read from its
standard input. This is the most common case.
CLIPBOARD_STATE=nil
Indicates that the clipboard is empty. In this case the spawned command's standard input
will be attached to /dev/null. Note that this is subtly different from the clipboard
containing zero-sized data (which can be achieved, for instance, by running wl-copy <
/dev/null).
CLIPBOARD_STATE=clear
Indicates that the clipboard is empty because of an explicit clear request, such as after
running wl-copy --clear. As for nil, the command's standard input will be attached to
/dev/null.
CLIPBOARD_STATE=sensitive
Indicates that the clipboard contains sensitive data such as a password or a key. It is
probably best to avoid visibly displaying or persistently saving clipboard contents.
Any client programs implementing the CLIPBOARD_STATE protocol are encouraged to implement proper
support for all the values listed above, as well as to fall back to some sensible behavior if
CLIPBOARD_STATE is unset or set to some unrecognized value (this is to leave the design space open
for future extensions). However, the currently existing Wayland clipboard protocols don't let
wl-clipboard identify the cases where clear and sensitive values should be set, so currently
wl-clipboard only ever sets CLIPBOARD_STATE to data or nil.
The CLIPBOARD_STATE protocol was intentionally designed to not be specific to either wl-clipboard
or Wayland; in fact, other clipboard tools are encouraged to implement the same protocol.
Currently, the SerenityOS paste(1) utility is known to implement the same CLIPBOARD_STATE
protocol.
Examples
Copy a simple text message:
$ wl-copy Hello world!
Copy a message starting with dashes:
$ wl-copy -- --long
Copy the list of files in ~/Downloads:
$ ls ~/Downloads | wl-copy
Copy an image:
$ wl-copy < ~/Pictures/photo.png
Copy the previous command:
$ wl-copy "!!"
“Well they're not gonna feel any better about their life if you get clipped” ~ Tony Soprano
Related Linux commands
csplit - Split a file into context-determined pieces.
paste - Merge lines of files.
tail - Output the last part of files.
xclip - Copy to clipboard (X11).
wl-paste - Paste from clipboard (Wayland).
Equivalent Windows command: CLIP - Copy to clipboard.
Copyright © 1999-2026 SS64.com
Some rights reserved