[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Menu-entry and Variable holding X-clipboard



Gus <gusl@cse.unsw.edu.au> writes:

> you'll probably have to write a wrapper program that grabs the
> clipboard and passes it as an argument
> 
> this shouldn't be too hard - i'll leave it up to someone with some X
> experience to give you the code ;)

OK, here's something I prepared earlier, which should give you some
ideas.  I think I worked out how to do it by looking at xpaste or
something like it.

-----
#include <X11/Xlib.h>
#include <X11/Xatom.h>
void main(int argc, char *argv[])
{
    Display *display = XOpenDisplay("");
    char *string;
    int bytes;
    XConvertSelection(display, XA_PRIMARY, XA_STRING, XA_CUT_BUFFER0,
        XDefaultRootWindow(display), CurrentTime);
    string = XFetchBytes(display, &bytes);
    write(1, string, bytes);
    XFree(string);
    XCloseDisplay(display);
}
-----

If you compile this as xprtsel, for example, you could run:

    $ myprogram -clipboard "`xprtsel`"

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/

	     "I'm not a god.  I've just been misquoted."


Reply to: