21

Since they are "saved to clipboard", the contents must be stored somewhere.

Are they stored in a file?

TellMeWhy
  • 17,484
  • As far as i know, there isn't a file per se. X server stores contents internally. There's some apps that can copy stdin of terminal into clipboard ( its actually called selection in X server). I'm gonna download the sorce code, I'll let you know what i can find – Sergiy Kolodyazhnyy Feb 03 '16 at 22:02
  • 3
    See http://standards.freedesktop.org/clipboards-spec/clipboards-latest.txt and https://wiki.archlinux.org/index.php/clipboard – Panther Feb 03 '16 at 22:24

3 Answers3

20

There are 3 clipboards usually available to users on Linux.

These clipboards are called "Selections".

There is:

  • PRIMARY: This is normally used for middle mouse button = copy/paste
  • SECONDARY: Normally not used by much, but it exists. Often as an in-app specific copy and paste.
  • CLIPBOARD: Usually Ctrl+c and Ctrl+v style copy and paste.

All of them are stored, by default, in memory of the controlling application (usually Xorg, but not always). And every child application has access to it.

Clipboard monitors and managers exist that can monitor the clipboards and store their contents in a file, or more commonly, let you review your clipboard history.

Pablo Bianchi
  • 15,657
coteyr
  • 18,288
  • 31
    "You seem to be lacking an understanding of clipboards in Linux." is a completely unnecessary sentence. I'm pretty sure that's the reason why they are asking a question. – AndiChin May 22 '20 at 14:27
  • 4
    You seem to be lacking understanding of clipboards in Linux :) the answer is not quite accurate. The xserver doesn't store any selection in memory, it brokers requests to access the selections: The client that owns a selection registers a callback with X to be called when another application asks for the selection. The owning client may or may not have a copy of the selection in memory, it just need to provide means of sending it, i.e. the callback. – johannes_lalala Jul 03 '20 at 00:55
5

What clipboard? There are some apps/tools that can be used to store clipboard contents to a file on disk, but the core clipboard feature in X11 simply keeps what is in the clipboard, in memory. It is not stored in a file on disk.

dobey
  • 40,982
3

On my Xubuntu system, I have Clipman installed, and I find the clipboard contents at /home/YourUsername/.cache/xfce4/clipman/textsrc. Yes, that's a cache file, but can be saved even after rebooting my system. It's not a MEMORY cache, which is cleared on, say, reboot.

However, if you quit Clipman and then restart, the data will be lost. So, if you want your items to be saved no matter what, you can open the file with, say, mousepad, copy the contents, create a new file named ClipboardHistory*date*.txt in, say, your documents folder, paste into it and save before closing.

You can restore the contents by the reverse process. You can also edit the contents this way if you want (you may want to delete the clipboard entry containing all the text if it duplicates!) On other environments the idea is probably the same, the names of the programs will be different, however.

Esther
  • 3,600
  • 13
  • 29
fixitmanarizona
  • 190
  • 1
  • 7