hi,
these are some fairly interesting utilities
http://cvs.windowmaker.org/co.php/wm/util/wxpaste.c
just put the source code in a clean directory and comment out
// #include "../src/config.h"
and compile with
gcc -o wxpaste -L/usr/X11R6/lib -lX11 wxpaste.c
it doesn't need any of windowmaker
however i don't think this is going to do what you want
it only seems to grab stuff from the same term it's run in ?
also appears to grap emacs yanks
but not copy from qt or gtk apps
there might be something i'm missing and i'm abslutely sure it could be easily fixed to use
qt or gtk paste as a command line option
just for fun you might mess with it and see if you can get it to do more