70

I'm constantly frustrated by the two separate clipboards in X/Gnome. I'm constantly doing things like control-C to copy, and then middle-click to paste, and getting the wrong data. Or select something, then go where I want to paste it, and selecting what I want to paste over, only to lose my first selection!

Is there any way to merge these two clipboards?

Update: Parcellite comes close, but pasting over a selection is really essential. Is there a way to disable select-as-copy in X?

TREE
  • 1,257
  • 1
  • 9
  • 14
  • It's been 3 years. Do we have solution to this problem? – Varun Mar 20 '13 at 13:05
  • Nope. For various other reasons, I've switched to KDE recently. klipper is acceptable for kde + synergy, but I know of no usable solution for gnome + synergy. Problems with autocutsel, parcellite and glipper are all laid out in existing answers and comments on this question. – TREE Mar 20 '13 at 17:16
  • I think the problem is exactly because you tried to join them. now you are probably overwritting the ctrl+c one with selections. If you force yourself to use only Ctrl+c/Ctrl+v, then you can either ignore selection/middle+click or use it as an isolated, alternative one. Just never use selection/middle+click (or shift+ins). stick with ctrl+c/ctrl+v and you don't have the problem – gcb Jun 08 '15 at 07:24

9 Answers9

36

autocutsel is what you want to sync between the primary X/X11 clipboard and the Gnome/GTK clipboard! Here's how:

$ autocutsel &
$ autocutsel -s PRIMARY & 

Magic!

a paid nerd
  • 3,332
  • 6
  • 30
  • 32
  • 1
    Hell yeah ! add this to my ``.bashrc`` – Natim Feb 26 '13 at 10:47
  • Note that this seems to redirect writes on "PRIMARY" to "CLIPBOARD" but it does not redirect writes on "CLIPBOARD" back to "PRIMARY" – Peeyush Kushwaha Jan 11 '21 at 07:46
  • A working solution to the limitation I mentioned can be found using the GUI tool `diodon`: https://unix.stackexchange.com/a/628496/39009 – Peeyush Kushwaha Jan 11 '21 at 08:15
  • Try using it with [clipboard-indicator](https://extensions.gnome.org/extension/779/clipboard-indicator) gnome extension! Here's an [rpm](https://ftp.lysator.liu.se/pub/opensuse/distribution/leap/15.3/repo/oss/x86_64/autocutsel-0.10.0-1.17.x86_64.rpm) version that works great on RHEL8. – Noam Manos Aug 19 '22 at 22:10
35

"autocutsel" will not do what you want.

This issue has existed for over a decade, till I found a fix a few weeks back.

You need to do this:

apt-get install parcellite

Right click go on the icon and go to the "Preference"

Check the following:

  • Use Copy (Ctrl-C)
  • Use Primary (Selection)
  • Sync clipboards
Spooky
  • 428
  • 5
  • 13
Warren Noronha
  • 451
  • 4
  • 3
  • 3
    parcellite appears to successfully merge the clipboards. It does not solve the latter problem, which is pasting over a selection. I like that I can paste a single buffer with either control-v or middle button. I do not like (and would like to disable) selection as copy. – TREE Apr 12 '10 at 13:28
  • Autocutsel works inconsistently (or not at all). It has been so frustrating, thanks for this. – NSAutomaton May 16 '16 at 13:00
  • 1
    `sudo yum install parcellite` for RHEL / CentOS – Noam Manos Jan 09 '18 at 11:58
  • FYI, **parcellite** has cool feature - **history of copied text**. To activate auto-paste from history dialog, you should also `install xdotool` – Noam Manos Jan 25 '18 at 13:52
  • This one worked for me. – Farhan.K Mar 12 '18 at 10:36
  • There is no "preference" for Parcellite on Ubuntu 18. What exactly do you mean by `Right click go on the icon and go to the "Preference"`? which icon? – Dima Lituiev Apr 19 '20 at 16:55
  • parcellite seems to be deprecated as of ubuntu 20.04. I've used it long ago, as well as clipit. Now I am going back to autocutsel. – spacediver Aug 20 '20 at 10:30
7

So I actually like to keep the various copy buffers separate, and occasionally sync from one or the other (like when I'm using keepass2.) So if I want to move something from the clipboard to the primary copy (middle mouse button) buffer, I'll do:

xclip -o -selection clipboard | xclip -i 
Pylsa
  • 30,630
  • 16
  • 89
  • 116
Dale
  • 71
  • 1
  • 1
2

It's not gnome, but Klipper from KDE has an option to do this. I'm getting frustrated by the lack of it in gnome as well.

Daenyth
  • 6,290
  • 2
  • 28
  • 22
  • I tried Glipper, which had a decent workaround for the selection problem: when you've destroyed your previous selection by selecting something else, Glipper lets you access the history and get back what you had. However, it interferes with Synergy clipboard sharing, which is a non-starter. :( – TREE Jul 02 '10 at 12:33
2

I think autocutsel will solve your problem. Most distro package cleverly as "autocutsel". In ubuntu it's in the universe repository.

DaveParillo
  • 14,505
  • 1
  • 39
  • 46
  • This looked really promising, but running it doesn't appear to change anything. :( – TREE Nov 12 '09 at 20:36
  • Can you give an exact example? Copy from X (using ctrl-C) to Y (using middle mouse button)? I think I may not understand your exact situation. – DaveParillo Nov 13 '09 at 06:12
1

CopyQ seems to do this as well.

To enable it, open CopyQ Preferences, and set it under General - Clipboard Manipulation:

enter image description here

Noam Manos
  • 1,804
  • 1
  • 20
  • 20
  • I've just tested, it is not. Do you know exact option to turn on perhaps?) – spacediver Aug 20 '20 at 10:31
  • @spacediver Yes, let me at that to the answer. – Hielke Walinga Aug 20 '20 at 11:20
  • _Parcellite_ was my favorite, but it's not maintained anymore, so I switched to _CopyQ_ - that can sync primary selection and clipboard, while keeping the option to paste from clipboard with "ctrl+v", and paste from primary with middle mouse button. – Noam Manos Nov 24 '21 at 16:58
1

As of 0.9.2-1 (Debian Squeeze), parcellite seems to be merging the two clipboards (Primary & Selection), while autocutsel 0.9.0-1 does work most of the time, but fails randomly.

CHEN Cheng
  • 11
  • 1
1

loliclip (current name: xcmenu) does what I was searching for when I bumped into this question. It effectively disables copy on mouse selection by forcing primary buffer to be in sync with clipboard. With default config after start this program you can copy by Ctrl+C (or Ctrl+Insert) and paste it by Ctrl+V (or Shift+Insert).

user1742529
  • 264
  • 2
  • 10
glebtv
  • 61
  • 3
0

Problem 2 happens because both copying by selecting and pasting with middle-click move text to/from the same buffer, the primary selection buffer. To change that, I think you would have to modify and recompile Xorg. But I could be wrong.

It would be easier to solve both problems without requiring pasting with middle-click. This would require explicit copy/paste, like what Ctrl + C / Ctrl + V do for desktop apps, but it would work for any X app.

We need a program that copies the X selection to the clipboard, and another program that pastes the clipboard to the cursor. Then you can bind those to some universal key combos. I don't know if there are any programs like that yet.

Lee Taylor
  • 1,466
  • 1
  • 17
  • 22