1

As is known to all of us, clipboard is managed by the program itself in most Linux distribution, which means that the content in clipboard will disappear when the hosting program halts.

However, clipboard managers like xclip seems to be exceptions. Even we got return value from these programs, we still can paste contents from the clipboard. So, I wonder if it possible to make xclip a daemon service which realtime backups content in clipboard. In this way, we can still available to paste contents from clipboard even if the original program halts for every process.

If so, I believe it will save a lot efforts, especially you don't need to re-open your closed libreoffice to re-copy in order to paste some sentences.

2 Answers 2

2

If you are planning to write your own clipboard manager, you might look at this python example which uses the gtk library to do most of the work. You might want to change SELECTION_CLIPBOARD to SELECTION_PRIMARY. The class is documented here.

Selections can be rich text, or images, but if you only want to handle text it can be simpler. This much shorter example just prints the selection every time it changes, and might be enough for you to keep a history of text selections.

parcellite claims to do what you want, keeping a history of selections, but I cannot test it as I don't use a suitable desktop environment.

If you use gnome, you can try gpaste, which should be available as a package. It is a clipboard manager, but seems to use dbus rather than the X11 selection mechanism, so it may not work with pure X11 clients, but only gnome applications.

autocutsel could also be a starting point if you program in C. It copies the PRIMARY selection to cutbuffer 0 whenever it changes, to provide compatibility with some other systems when using VNC.

0

Have a look at xclipboard. Unfortunately, it only stores CLIPBOARD selections, while most modern X applications only use PRIMARY selections ...

But the source is available, you can change it as you like.

1
  • It's true that most modern X applications only use PRIMARY. However, when you close the application, content that you manually copied by Ctrl-c will also lose. I want a clipboard manager who can solve this problem. However xclip can't. I'm now reading Freedesktop documents. And I hope in one day I can write a xclipboard daemon. But anyway, thanks.
    – TJM
    Nov 13, 2017 at 4:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .