in reply to Using X selection: copy and paste

I had good luck with xsel by Conrad Parker. You can open pipes to read from and write to the different selection buffers (default is PRIMARY).