astrand/xclip

Error: target STRING not available

baditaflorin opened this issue · 6 comments

I'm getting this error when trying to run xclip in MacosX, using brew install xclip

Also tried this but will never increment even if I do right click copy or Command C to copy to clipboard
xclip -loops 10 -verbose $(pwd)/file.txt
Loops: 10
Connected to X server.
Using UTF8_STRING.
Reading /Users/florin/Coding/LINUX/file.txt...
Waiting for 10 selection requests, Control-C to quit
Waiting for selection request 1 of 10.

Hi!

I don't know how MacOS's clipboard integrates with the X selection, but I seem to recall there was an option to synchronize them in the MacOS X server. Have you looked into that?

It's also possible for STRING to not be available, although that seems unlikely if you've been copying text. Would you please run this and let us know what the output is:

xclip -t TARGETS

As for -loops, it only counts the number of paste requests. When you do a copy with another X application, as you were doing, xclip is supposed to quit even if the number of loops hasn't changed. The fact that it doesn't makes me suspect there is something weird going on with MacOS's clipboard integration with X.

@baditaflorin Did you get it figured out?

unfortunately no, I did not manage yet to play with it too much.
I do not get anything when running this command. If I start writing, it will add the text, and need to to CTRL+C to quit

xclip -t TARGETS
^C

Oh, I forgot with the older release of xclip that brew likely has, you need to include -o or it will read from stdin. Please try,

xclip -o -t TARGETS

PR #142 might help here. I noticed that some applications require STRING to be set for anything else to work.

While investigating an xclip issue elsewhere I also stumbled upon this bug report.
It seems that certain versions of xclip "wait" for the receiver to specify the acceptable mime types; this causes a problem when the receiver is a pipe. For example, in Debian 13,

$ xclip -version
xclip version 0.13
Copyright (C) 2001-2008 Kim Saunders et al.
Distributed under the terms of the GNU GPL

$ xclip -t TARGETS -o
Error: target TARGETS not available

I suspect this is because the console does not offer any kind of 'targets' to xclip.
The curious matter is that, once I "initialise" the clipboard by copying some text into it from any application, running the command again returns something else:

$ xclip -t TARGETS -o
TIMESTAMP
TARGETS
MULTIPLE
UTF8_STRING
COMPOUND_TEXT
TEXT
STRING
text/plain;charset=utf-8
text/plain