Clipboard

From ArchWiki
Revision as of 13:19, 29 April 2015 by Pfrenssen (talk | contribs) (Add section to introduce basic inspecting of the clipboard and writing to it.)
Jump to navigation Jump to search

From Wikipedia:Clipboard (computing):

The clipboard is a facility used for short-term data storage and/or data transfer between documents or applications, via copy and paste operations.

History

In X10, "cut buffers" were introduced. These were limited buffers that stored arbitrary text and were used by most applications. However, they were inefficient and implementation of them varied, so selections were introduced. Cut buffers are long deprecated, and although some applications (such as xterm) may have legacy support for them, it is both not likely and not recommended that they be used.

Background

The ICCCM (Inter-Client Communication Conventions Manual) standard defines three "selections": PRIMARY, SECONDARY, and CLIPBOARD. Despite the naming, all three are basically "clipboards". Rather than the old "cut buffers" system where arbitrary applications could modify data stored in the cut buffers, only one application may control or "own" a selection at one time. This prevents inconsistencies in the operation of the selections. However, in some cases, this can produce strange outcomes, such as a bidirectional shared clipboard with Windows (which uses a single-clipboard system) in a virtual machine.

Of the three selections, users should only be concerned with PRIMARY and CLIPBOARD. SECONDARY is only used inconsistently and was intended as an alternate to PRIMARY. Different applications may treat PRIMARY and CLIPBOARD differently; however, there is a degree of consensus that CLIPBOARD should be used for Windows-style clipboard operations, while PRIMARY should exist as a "quick" option, where text can be selected using the mouse or keyboard, then pasted using the middle mouse button (or some emulation of it). This can cause confusion and, in some cases, inconsistent or undesirable results from rogue applications.

Inspecting and setting the clipboard

You can inspect and manipulate the clipboard using xsel. Use the -p option for the PRIMARY buffer, and the -b option for the CLIPBOARD buffer.

Inspect the PRIMARY buffer.

$ xsel -p

This is the default buffer so you can choose to omit the -p option:

$xsel

Inspect the CLIPBOARD buffer:

$ xsel -b

You can set the clipboard buffers by piping content into it. For example to write the output of uptime to the PRIMARY buffer:

$ uptime | xsel -p

This means you can easily copy the content of one buffer to another by piping to xsel itself. For example you can copy the contents of the PRIMARY buffer into CLIPBOARD so you can paste it with the keyboard:

$ xsel | xsel -p

List of clipboard managers

Clipboard managers are applications that enable users to manipulate the clipboard. Note that many of these programs can also synchronize the previously mentioned clipboards.

  • Anamnesis — Clipboard manager that stores all the clipboard history and offers an interface to do a full-text search. It has both a command line and GUI mode available.
http://anamnesis.sourceforge.net/ || anamnesisAUR
  • Autocutsel — Command line and daemon interfaces to synchronize PRIMARY, CLIPBOARD and cut buffer selections.
http://www.nongnu.org/autocutsel/ || autocutsel
  • ClipIt — Fork of Parcellite with additional features and bugfixes.
http://sourceforge.net/projects/gtkclipit/ || clipit
  • Clipman — A clipboard manager for Xfce. It keeps the clipboard contents around while it is usually lost when you close an application. It is able to handle text and images, and has a feature to execute actions on specific text selections by matching them against regular expressions.
http://goodies.xfce.org/projects/panel-plugins/xfce4-clipman-plugin || xfce4-clipman-plugin
  • Clipmenu — Dmenu based clipboard manager
https://github.com/cdown/clipmenu/ ||
  • CopyQ — Clever clipboard manager with searchable and editable history, custom actions on items and command line support.
https://github.com/hluk/CopyQ || copyqAUR
  • Glipper — Clipboard manager for the GNOME desktop with many features and plugin support.
https://launchpad.net/glipper || glipperAUR
  • GPaste — Clipboard management system that aims at being a new generation Parcellite, with a modular structure split in a couple of libraries and a daemon for adaptability. Offers a GNOME Shell extension and a CLI interface.
https://github.com/Keruspe/GPaste || gpasteAUR
  • Klipper — Full featured clipboard manager for the KDE desktop.
http://userbase.kde.org/Klipper || kdebase-workspace
  • Parcellite — Lightweight yet feature-rich clipboard manager.
http://parcellite.sourceforge.net/ || parcellite
  • Pasteall — Clipboard monitor simple and functional.
https://github.com/LaraCraft93/Pasteall || pasteallAUR
  • Qlipper — Lightweight and cross-platform clipboard history applet based on Qt.
https://code.google.com/p/qlipper/ || qlipperAUR
  • Xclip — A lightweight, command-line based interface to the clipboard.
http://sourceforge.net/projects/xclip/ || xclip
  • xcmenu — Clipboard synchronizer developed for window manager users.
https://github.com/Cloudef/xcmenu || xcmenu-gitAUR

See also