wl-paste Man Page - Linux

Paste from clipboard (Wayland).

Syntax
      wl-paste [--primary] [--type mime/type]

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

   -l, --list-types
           Instead of pasting the selection, output the list of MIME types it is offered in.

   -n, --no-newline
           Do not append a newline character after the pasted clipboard content. This option is automatically
           enabled for non-text content types and when using the --watch mode.

   -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-paste it controls which of the offered types
           wl-paste will request the content in. In addition to specific MIME  types such as image/png, wl-paste
           also accepts generic type names such as text and image which make it automatically pick some offered
           MIME type that matches the given generic name.

   -w command..., --watch command...
           Instead of pasting  once  and exiting, continuously watch the clipboard for changes, and run the
           specified command each time a new selection appears. The spawned process can read the clipboard
           contents from its standard input. wl-paste also sets the CLIPBOARD_STATE variable in the
           environment of the spawned processes (see below).

           This mode requires a compositor that supports the wlroots data-control protocol.

   -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

Paste to a file, without appending a newline:

$ wl-paste -n > clipboard.txt

Sort clipboard contents:

$ wl-paste | sort | wl-copy

Copy the list of files in ~/Downloads:

$ ls ~/Downloads | wl-copy

Upload clipboard contents to a pastebin on each change:

$ wl-paste --watch nc paste.example.org 5555

“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-copy - Copy to clipboard (Wayland).
Equivalent Windows command: CLIP - Copy to clipboard.


Copyright © 1999-2026 SS64.com
Some rights reserved