How to delete the clipboard in the middle wheel

18,631

It's because there are actually two clipboards: GNOME has one and X.org has one.

You can paste the text which is on GNOME's clipboard by right clicking an text area and then selecting "paste".

X's clipboard works as the following: when you select text by keeping mouse's left button klicked and move mouse, it is copied to X's clipboard. Then you can paste it by clicking mouse's middle button.

Excerpt from archlinux's wiki page clipboard:

Of the three selections, users should only be concerned with PRIMARY and CLIPBOARD. SECONDARY is only used inconsistently and was intended as an alternate to PRIMARY. Different applications may treat PRIMARY and CLIPBOARD differently; however, there is a degree of consensus that CLIPBOARD should be used for Windows-style clipboard operations, while PRIMARY should exist as a "quick" option, where text can be selected using the mouse or keyboard, then pasted using the middle mouse button (or some emulation of it).

Therefore, the clipboard of GNOME is type CLIPBOARD and the clipboard of X is type PRIMARY.

Delete the contents of X clipboard

Excerpt from xclip's man page:

-i, -in
read text into X selection from standard input or files (default)

Therefore, to clear the contents of X clipboard, use the following command:

$ xclip -i /dev/null

Delete the contents of CLIPBOARD clipboard (GNOME's clipboard)

$ touch blank
$ xclip -selection clipboard blank

References

Share:
18,631

Related videos on Youtube

thywoae
Author by

thywoae

Updated on September 18, 2022

Comments

  • thywoae
    thywoae over 1 year

    Right click on the text field the popup mouse menu shows that the clipboard is blank, but when press the wheel in the middle of the mouse the previous selected text is pasted.

    Why is this and how can I clear that text?

    Gnome 3.6.2 + opensuse 12.3

  • slm
    slm over 10 years
    See the links I provided on the Q, they explain the multiple clipboards very well and they're wihin the U&L site.
  • Admin
    Admin over 10 years
    @slm You're right, the A's of those Q's explain clipboard better than my answer.
  • slm
    slm over 10 years
    Add them into your A if you like as references, I can remove them so they're more inline with your A. This Q isn't a duplicate and your A should be the correct one if you can add a method to delete the contents of the clipboard. The 2 links show how to do that so just add this bit to your A.
  • Pierre ALBARÈDE
    Pierre ALBARÈDE over 3 years
    As the middle button is also the scrolling wheel on my mouse, scrolling makes accidental copies of X clipboard in my code. This can be avoided by clearing the X clipboard as explained so the question and the answer are very valuable to me, thank you.