71

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?

3
  • It's been 3 years. Do we have solution to this problem?
    – Varun
    Mar 20, 2013 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, 2013 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 8, 2015 at 7:24

9 Answers 9

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!

4
  • 1
    Hell yeah ! add this to my .bashrc
    – Natim
    Feb 26, 2013 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" Jan 11, 2021 at 7:46
  • A working solution to the limitation I mentioned can be found using the GUI tool diodon: unix.stackexchange.com/a/628496/39009 Jan 11, 2021 at 8:15
  • Try using it with clipboard-indicator gnome extension! Here's an rpm version that works great on RHEL8.
    – Noam Manos
    Aug 19, 2022 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
7
  • 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, 2010 at 13:28
  • Autocutsel works inconsistently (or not at all). It has been so frustrating, thanks for this. May 16, 2016 at 13:00
  • 1
    sudo yum install parcellite for RHEL / CentOS
    – Noam Manos
    Jan 9, 2018 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, 2018 at 13:52
  • This one worked for me.
    – Farhan.K
    Mar 12, 2018 at 10:36
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 
2

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

2
  • This looked really promising, but running it doesn't appear to change anything. :(
    – TREE
    Nov 12, 2009 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. Nov 13, 2009 at 6:12
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.

1
  • 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 2, 2010 at 12:33
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.

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).

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

3
  • I've just tested, it is not. Do you know exact option to turn on perhaps?)
    – spacediver
    Aug 20, 2020 at 10:31
  • @spacediver Yes, let me at that to the answer. Aug 20, 2020 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, 2021 at 16:58
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.

1
  • I don't think it require recompiling xorg because klipper does it perfectly..
    – neutrinus
    Nov 4, 2015 at 8:41

You must log in to answer this question.

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