how to purge the x selection/clipboard?

2 views
Skip to first unread message

Javier

unread,
Mar 25, 2019, 8:04:58 AM3/25/19
to
Why this is not purging the x selection/clipboard?

xsel -dp; xsel -db; xsel -ds; # This doesn't work
xsel -cp; xsel -cb; xsel -cs; # This doesn't work either

echo | xsel -ip # works, but there's a newline in the selection
printf '' | xsel -ip # This has no effect the selection

Kenny McCormack

unread,
Mar 25, 2019, 9:43:54 AM3/25/19
to
In article <osedncYOkqF0XgXB...@brightview.co.uk>,
I've been bitten by this one, too.

But note:
1) I think it has to do with the fact that -d is ambiguous between being
the usual XToolkit option for DISPLAY and being a tool-specific option for
delete.
2) --delete works

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/ThePublicGood

Javier

unread,
Mar 25, 2019, 10:32:35 AM3/25/19
to
> 1) I think it has to do with the fact that -d is ambiguous between being
> the usual XToolkit option for DISPLAY and being a tool-specific option for
> delete.
> 2) --delete works

You are right that -d is a bad option name for an X program.

In any case, I am testing --delete and it doesn't do anything at all.

xsel --delete --primary
xsel --delete --clipboard

Kenny McCormack

unread,
Mar 25, 2019, 11:01:33 AM3/25/19
to
In article <wsCdnYfuroAcewXB...@brightview.co.uk>,
It works for me:

$ xsel -ip <<< "THis is a test"
$ xsel -p
THis is a test
$ xsel -p --delete
$ xsel -p
$

(That's how I tested it. I doubt the option order matters.)

--
"They say if you play a Microsoft CD backwards, you hear satanic messages.
Thats nothing, cause if you play it forwards, it installs Windows."

Javier

unread,
Mar 25, 2019, 12:50:03 PM3/25/19
to
> It works for me:
>
> $ xsel -ip <<< "THis is a test"
> $ xsel -p
> THis is a test
> $ xsel -p --delete
> $ xsel -p
> $

'xsel --delete --primary' doesn't clear the primary selection in xterm,
the highlighted text is still there. However, if I type 'echo | xsel -ip'
the highlighted text goes away.

My guess is that Xterm is making things more complex using CUT_BUFFER0
in addition to the PRIMARY selection. Sometimes I even get text selected
long time ago in some other xterm window when clearing the selection.

From xterm(1):

~Meta <Btn1Down>:select-start()
<BtnUp>:select-end(SELECT, CUT_BUFFER0) \n
~Ctrl ~Meta <Btn2Up>:insert-selection(SELECT, CUT_BUFFER0)

I don't understand the difference between SELECT, CUT_BUFFER0 and
PRIMARY.

The workaround I'm using now is

echo | xsel --input --primary # puts a newline in the primary selection
# and clears the XTerm highlighted text

Kenny McCormack

unread,
Apr 1, 2019, 9:00:14 AM4/1/19
to
In article <wsCdnYfuroAcewXB...@brightview.co.uk>,
Javier <jav...@invalid.invalid> wrote:
Update: I just had an instance where --delete didn't work for me (as well).

It does seem to be a little murky. The clipboard implementation in X is
kinda weird/primitive, although elegant in a certain way.

As you say in a later followup, it seems to be dependent on which
"xterm-like" terminal program you're running. I just had an instance
running in LXterminal where:

xsel --delete -b

didn't do anything. The contents of the -b clipboard stayed intact.

However, the following worked in this instance, and I *think* that it will
always work:

xsel -ib < /dev/null

P.S. There is some functionality of xsel where it "backgrounds" itself.
That is, you do a "ps" listing and it shows "xsel" processes running in the
background. The "man page" explains this, but it never made any sense to
me. In any case, you might try killing these processes; that may cause the
clipboard contents to vanish. Worth a try...

--

"This ain't my first time at the rodeo"

is a line from the movie, Mommie Dearest, said by Joan Crawford at a board meeting.
Reply all
Reply to author
Forward
0 new messages