LinuxCommandLibrary

wl-paste

Paste Wayland clipboard data to standard output

TLDR

Paste the contents of the clipboard

$ wl-paste
copy

Paste the contents of the primary clipboard (highlighted text)
$ wl-paste --primary
copy

Write the contents of the clipboard to a file
$ wl-paste > [path/to/file]
copy

Pipe the contents of the clipboard to a command
$ wl-paste | [command]
copy

SYNOPSIS

wl-paste [-p | --primary | -s | --selection] [-t MIME_TYPE | --type MIME_TYPE] [-f | --list-types] [-w | --wait | -c | --continuous] [-n | --no-newline] [-v | --verbose] [-h | --help] [--version]

PARAMETERS

-p, --primary
    Uses the primary selection buffer instead of the default clipboard. The primary selection is typically used for instant paste of highlighted text without an explicit copy action.

-s, --selection
    An alias for --primary, also specifying the primary selection buffer.

-t MIME_TYPE, --type MIME_TYPE
    Specifies a preferred MIME type (e.g., "text/plain", "image/png", "text/html") for the content to be pasted. If the requested type is not available, wl-paste may fall back to "text/plain" or fail.

-f, --list-types
    Lists all available MIME types for the current content in the clipboard or selected buffer, rather than pasting the content. This is useful for inspection.

-w, --wait
    Instructs wl-paste to wait indefinitely until new clipboard content becomes available before pasting it and then exiting. Useful for scripting reactive behaviors.

-c, --continuous
    Continuously outputs new clipboard content to standard output as it changes. The command will not exit until manually terminated (e.g., via Ctrl+C).

-n, --no-newline
    Prevents wl-paste from appending a newline character to the output. Useful when pasting text into a specific context without extra line breaks.

-v, --verbose
    Enables verbose output, printing informational and debugging messages to standard error. This can assist in troubleshooting.

-h, --help
    Displays a brief help message explaining command usage and options, then exits.

--version
    Displays the version information for the wl-paste utility and exits.

DESCRIPTION

wl-paste is a command-line utility designed for interacting with the Wayland clipboard. It is a fundamental part of the wl-clipboard suite, which aims to provide simple, command-line access to Wayland's copy-paste mechanisms, much like xclip or xsel do for Xorg. Specifically engineered for Wayland compositors, wl-paste retrieves the current content of the clipboard (or selection buffer) and prints it to standard output.

This functionality is crucial for seamless integration into shell scripts, enabling users to pipe clipboard content to other commands, save it to files, or simply view its contents directly from the terminal. The utility effectively handles various MIME types, defaulting to converting content to plain text, but also offering options to specify or list other available formats. Furthermore, wl-paste supports advanced features such as waiting for new clipboard content and continuously monitoring for changes, making it a versatile tool for Wayland users.

CAVEATS

wl-paste strictly requires a running Wayland compositor to operate; it is not compatible with X11 environments. For X11, users should utilize tools like xclip or xsel. The specific behavior and range of available MIME types for clipboard content can sometimes vary depending on the Wayland compositor in use and the application from which the content was originally copied.

WAYLAND CLIPBOARD BUFFERS

Wayland environments typically manage multiple selection buffers, primarily the 'clipboard' and the 'primary selection'. The standard clipboard, often associated with copy (Ctrl+C) and paste (Ctrl+V) actions, is the default target for wl-paste. The primary selection, common in X11 and supported in Wayland, allows for text to be pasted simply by highlighting it, without an explicit copy command. Users can interact with the primary selection by using the -p or --primary option with wl-paste.

MIME TYPE FLEXIBILITY

Wayland's clipboard protocol supports offering content in various MIME types simultaneously, allowing applications to provide data in formats ranging from simple 'text/plain' to complex 'image/png' or 'text/html'. wl-paste intelligently negotiates with the source application to retrieve the most suitable format, defaulting to 'text/plain' for textual output. Users have control over this process: the -t option allows requesting a specific MIME type, while the -f option provides a list of all available types for the current clipboard content, offering significant flexibility in how data is retrieved.

HISTORY

The wl-clipboard project, which includes wl-paste, was developed to bridge a significant functional gap in the Wayland ecosystem: the absence of a simple, robust command-line utility for clipboard interaction, akin to xclip in Xorg. As Wayland gained traction as the successor to Xorg, the need for such a tool became increasingly apparent for scripting, automation, and general terminal-based workflows. wl-clipboard was thus created to provide native Wayland clipboard support, designed to be lightweight and efficient, and to fully leverage Wayland's protocol features like multiple selection buffers and diverse MIME type handling. Its ongoing development has been crucial in enhancing the usability and scripting capabilities of Wayland-based desktop environments.

SEE ALSO

wl-copy(1), xclip(1), xsel(1)

Copied to clipboard