#1865 Set PRIMARY selection when copying


Under X11, there are multiple clipboards.

Something called the PRIMARY selection is automatically set to whatever text is selected using the mouse. You can paste the contents of PRIMARY by clicking the middle mouse button in a text field.

The other clipboard works like the windows clipboard: you have to use a menu or a keyboard shortcut to copy and paste text.

KeePass uses xsel to put passwords into this second clipboard by passing it the --clipboard option. This is confusing if you're accustomed to middle-clicking to paste, because usually you have to select before copying, so text can't usually get into the clipboard without also getting into the primary selection.

If you pass both the --primary and --clipboard options to xsel, it will operate on both clipboards at once. I believe this behaviour is preferable.


  • Eric Siegerman

    Eric Siegerman - 2014-05-09

    Not all *nix users prefer X11's selecting-text-also-copies-it interface. I, for one, absolutely loathe it! Fortunately, most of of the programs I use either don't do it, or give me the option.

    I'm sure implementing this would be wonderful for those who like copy-on-select; but please make it optional, for the benefit of those of us who don't.


  • Peter Oliver

    Peter Oliver - 2014-05-09

    Hmm. I can understand your objection to "when-selecting-also-copy", but that's not what I'm proposing here, and I'm not even aware of any Unix programs that implement it. This is about "when-copying-also-select".

  • Eric Siegerman

    Eric Siegerman - 2014-05-15

    You're right; I misunderstood you.

    Many X programs do (or used to do) "when-selecting-also-copy". I hate that, but some people swear by it -- at least, they argue vehemently enough in favour of it :-) I overreacted, and assumed that that's what you were asking for. My apologies.

    Here's some background on X's longstanding cut/copy/paste issues. The when-selecting-also-copy behaviour that I thought you were asking for is what that document calls "historical interpretation A":

    use PRIMARY for mouse selection, middle mouse button paste, and explicit cut/copy/paste menu items

    But "Interpretation B" is what the document calls "the current consensus":

    use CLIPBOARD for the Windows-style cut/copy/paste menu items; use PRIMARY for the currently-selected text, even if it isn't explicitly copied, and for middle-mouse-click

    That's what I prefer, for all the reasons the document gives.

    What you were actually asking for, though, is something else entirely; indeed, it's one of the backgrounder's "guidelines to get correct behaviour":

    explicit cut/copy commands should always set both CLIPBOARD and PRIMARY, even when copying doesn't involve a selection (e.g. a "copy url" -option which explicitly copies an url without the url being selected first)

    I agree; that would make KeePass work better for me too.

    In summary, here's what I believe should happen:

    1. Do what you requested originally: KeePass's various "Copy thing" menu items should put thing into both PRIMARY and CLIPBOARD

    2. If interpretation A is ever implemented, it needs to be behind a preference setting so that individual users can continue to opt for interpretation B

    Last edit: Eric Siegerman 2014-05-15
  • Dominik Reichl

    Dominik Reichl - 2014-05-17
    • status: open --> closed
  • Dominik Reichl

    Dominik Reichl - 2014-05-17

    I've added this now. When using XSel, KeePass now puts the text into both the primary selection and the clipboard.

    Here's the latest development snapshot for testing:

    Thanks and best regards,


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks