From my understanding, under X11 we have basically 2 ways to copy and paste stuff: the PRIMARY selection and the CLIPBOARD selection. Explicitly copying something with ctrl-c will utilize the clipboard selection and there are many applications that may manage your clipboard for you.

But what I'm interested in is altering the PRIMARY selection behavior, in particular I wish to make X11 stop automatically copying selected text to the primary selection. My end goal is to be able to select text with my mouse and then middle-click with my mouse-wheel if I wish to copy it (or cut it if its easier to implement). I basically want to implement an extra step to copy stuff into PRIMARY.

I would also like to be able to paste this recently copied text by middle-clicking again the mouse. This is the default behavior for pasting the PRIMARY selection, so this should just work if we use the PRIMARY selection to copy stuff. (But if we somehow could remap everything to use CLIPBOARD we would gain the ability to paste images which I believe is impossible to do with PRIMARY)

What is the best way to accomplish this? Is this a xorg setting? Should I completely disable the PRIMARY selection and use some sort of keybinding application to implement this behavior with the CLIPBOARD selection? Is there a clipboard manager that can do this for me? I'm currently using Klipper, the clipboard manager that comes with KDE/plasma and this doesn't seem to be an option there.

1 Answer 1


My end goal is to be able to select text with my mouse and then middle-click with my mouse-wheel if I wish to copy it.

Each X11 application decides (and oftentimes hardcodes) what binding it uses to interact with Primary.

The traditional way to own Primary (as known as copy to Primary) is to simply make a selection and mouse-middle-click to paste from it. This was already the default for the Athena Widget Set (from the 80s, probably the first X widgets library), as you can see in its specification of the text widget. The binding can be altered for Athena and Motif applications via a translations X-resource (examples in Arch Wiki: XTerm and scrolling a single line in Xterm). The bad news is that such GUIs are legacy, and most modern X11 applications, based on Qt, GTK, etc., not only do not use a translations resource, but also oftentimes hardcode their keybidings.1

Moreover, although those Primary bindings are quite consolidated (the same for programs as old as XTerm to modern ones as Firefox), they are not written in stone. For a mouse-aware Ncurses program — e.g. Midnight Commander, Vim with mouse support enabled —, the copy binding is Shift+MouseSelection.2

Although nothing prevents a clipboard manager from snooping the Primary contents/ownership and controlling the Primary accordingly to arbitrary keybindings, in a manner similar to one described in Clipboard Managers section here, I don't think such a program exists yet.

Further reading:

1: For what it's worth, I have never seen a GTK or Qt application that would let me choose Primary keybindings.
2: Vim can copy to or paste from Primary with the keyboard only.

  • Actually Qt and GDK do use X resources (have "always" done so), but they don't use the X Toolkit library to access them (XGetDefault, for instance). If they didn't use X resources, they would be far more limited than they are. In the particular case you're mentioning though, it's mostly hard-coded stuff (very limited in comparison with other approaches). Apr 13, 2021 at 21:20
  • @Quasímodo, then it seems that I would be better off by just configuring everything through CLIPBOARD. Is there a way to disable copy to PRIMARY? or at least make it so that middleclicking pastes from CLIPBBOARD rather than PRIMARY. I dont want both selections fighting for dominance and keybindings
    – barzilay
    Apr 13, 2021 at 21:28
  • @barzilay See if you want to fuse PRIMARY and CLIPBOARD or maybe unix.stackexchange.com/q/213840. If neither is what you want, I'd recommend exploring the options of some clipboard managers as many allow a special handling of Clip and Primary.
    – Quasímodo
    Apr 13, 2021 at 21:58
  • @Quasímodo, Sadly neither of those work for me. If i only fuse them, then selecting text will pollute the shared clipboard, if there is a way to disable copying to PRIMARY then this would work for me. I'm trying a few clipboard managers but none of them so far can completely block copy to PRIMARY :/ but thank you for your time
    – barzilay
    Apr 13, 2021 at 22:23
  • 1
    See askubuntu.com/q/276975. All you need to do is to assign one of those commands to middle-click in your window manager. But yeah, that will break middle-clicking links. Likewise, you could assign a right click to copy to clipboard, but again this will break other functionalities that require right clicks. It's all about avoiding conflicts. In case you have trouble but find the issue worth pursuing, I advise you to open a new question and to make your requirements as clear as possible upfront.
    – Quasímodo
    Apr 16, 2021 at 12:38

You must log in to answer this question.

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