Starting X sessions in Cygwin

Question: "I want to have my Linux desktop in my Windows machine. I have installed Cygwin. How to do this?"

Follow these steps:
  • Start your Cygwin command shell.
  • Give "xinit -- -clipboard" in the command line. You will see a bare X window show with a command prompt in it. You will also see something like "Cygwin/X - 0:0" on the left-top of the window. This tells you the display in which the X server is listening for incoming connections.
  • Give "xhost +" in the command prompt. This is to let the server accept all the incoming connections. Remember: if you are concerned about the security, refer to the man page of xhost on how to give a list of hosts instead of wild card "+".
  • Start an ssh connection to your Linux box.
  • Once logged in, set the display variable. As per this example it would be "export DISPLAY=x.x.x.x:0.0" where x.x.x.x is the IP address of your Windows box.
  • Start your Gnome session by giving "gnome-session". Voila! You will see your desktop in your X window.
A couple of trouble shooting tips. If you have a firewall blocking connections from your Linux box to your Windows box, you will encounter an error. Just use telnet to make sure that your connection works. Try "telnet x.x.x.x 6000" to confirm this. It might be the case that you didn't do the "xhost +" step above, in which case your X server will reject the incoming connections. Make sure you have done this right.

A note on the "-clipboard" option above: if you don't give this option, X server doesn't share the windows clipboard with the applications running in it, hence you will not be able to copy/paste between your Windows and Linux applications.

Update on 1/28/2008: I found that giving the "-keyhook" option lets you switch between the frames inside Cygwin/X using Alt-TAB. You should give it like:
xinit -- -clipboard -keyhook

Comments

Anonymous said…
it worked perfect ! thanks!
tormp said…
i find that setting the DISPLAY variable in cygwin to ":0.0", and then tunnel X over ssh (ssh -X) gets you there too. adding -C to ssh seems to give a little performance kick when wire is slow, e.g. over VPN.

for example, in cygwin terminal:

> XWin -multiwindow -clipboard &
> export DISPLAY=":0.0"
> ssh -C -X -l user -f host /usr/X/bin/xterm -title "voila@hostname"

and there you go. X apps launched in the remote xterm magically pop up on the local win/cyg box.

i'm pretty ignorant of how the X tunneling works in ssh, there might be security considerations. but it works well for me.

maybe i'm unknowingly exploiting some clever env setup on the client side, but i don't think so.

Popular posts from this blog

The mysterious ORA-03111 error

Note on allocationSize parameter of @SequenceGenerator while using JPA

xVM's vboxmanage.exe command