/*
 * Build with:
 * gcc -o xselect -g xselect.c -lX11
 */
#include <X11/Xlib.h>

int main()
{
  Display *dpy;
  Window root;
  Atom primary;
  Atom utf8_string;
  XEvent event;

  dpy = XOpenDisplay(NULL);
  root = DefaultRootWindow (dpy);

  primary = XInternAtom (dpy, "PRIMARY", True);
  utf8_string = XInternAtom (dpy, "UTF8_STRING", True);

  XConvertSelection (dpy, primary, utf8_string, primary, root, CurrentTime);
  XSync (dpy, 0);

  while (XPending (dpy))
    XNextEvent(dpy, &event);

  return 0;
}

