How to use the X clipboard

Phil Betts
Tue Sep 18 11:02:00 GMT 2007

Robert Kiesling wrote on Tuesday, September 18, 2007 3:02 AM::

> I need to set the X server option, "emulate3Buttons," in order to use
> the X clipboard with the Cygwin system's mouse.  The FAQ tells me that
> I can add, "-emulate3buttons <ms>," to the X server arguments.
> However, if I start the server with
>   startx -- -emulate3buttons 10
> all of the X server's default arguments seem to get overriden.  I
> would like to know where are the X server resources are located so I
> can add this option without overriding the X server's default
> arguments.

You can create a script file .xserverrc in your home directory that is
called to actually start the server.  This could be something as simple

  exec /usr/X11R6/bin/X $@ -emulate3buttons 10

Here, if you run startx without any arguments, $@ will contain the 
display number (e.g. ":0"), but not the default server arguments, so 
you would need to add them to the above line yourself. For more 
information, man xinit.

Alternatively, start XWin using startxwin.bat and edit that to add
your own options.  It's a much simpler script than startx, so you're 
less likely to go astray.

> On a related note, the server and display addresses default to
>, and that limits clipboard use to clients on the local
> host.

Not true.  The display IS on the PC where you started it, therefore it
is on the localhost for clients started on the localhost.  The 
clipboard is available to all clients running on the server, wherever 
they may be.

> Because 
> this network gets its addresses through DHCP, I would like to know if
> there's a way to tell the X server beforehand what the network
> address is. I assume I can parse the output of Windows netstat after
> booting and add the address to /etc/hosts before starting the X
> server, but I would welcome any clues, hints, or suggestions how to
> go about telling the resolver library about the network address with
> a documented interface. 

There's no need for any of this.

Suppose the PC where you run the server is hosta and the remote box 
is hostb.  You start the server on hosta, where it is known as 

You then log into hostb.  From there, the server would be known as 
hosta:0, so you would set DISPLAY=hosta:0.

If hosta is not set up in your nameserver, then you would need to
use hosta's IP address, however it's still not necessary, nor is it
advisable.  If you connect directly to the server as a named host (or 
IP address), you either need to use XDMCP or the insecure xhost to 
allow access to your server from hostb.  The much preferred way is to 
use ssh with trusted X11 forwarding instead.

To do this, you log into hostb using:
  ssh -Y user@hostb

You need to ensure that $DISPLAY is set BEFORE you run ssh.  You can 
ensure this by running ssh like this:
  DISPLAY=localhost:0 ssh -Y user@hostb
However, if you start it from a cygwin shell, $DISPLAY should already
be set correctly.

On hostb, you will find that ssh has set up the DISPLAY to _look_ 
like it is connecting to a server on hostb - i.e. it will be 
localhost:10.0 or similar. Do not change this "because it looks wrong".
It simply means that ssh has opened a port on hostb (in this case 
6010), to which hostb's clients connect.  Traffic on this port is 
forwarded over the secure link to hosta's port 6000.

For more information (including what you may need to set up to
enable X11 forwarding), consult the FAQ:

Finally, this is the wrong list for X related questions. Check out

I've redirected replies to the correct list.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list