Skip to content. | Skip to navigation

Personal tools
You are here: Home Knowledge Automatically starting a cygwin X Window Server

Automatically starting a cygwin X Window Server

How to start cygwin's X Server when you log in - without annoying popup text windows.

At True Blade we make extensive use of cygwin, a Linux-like environment for Microsoft Windows. 

Cygwin lets us write all sorts of interesting scripts on Windows machines that would be difficult or impossible with normal Windows utilities.  One of the features we use most often is the secure shell (ssh) client, which lets us securely talk to Linux servers.

While cygwin is most often thought of as providing command line utilities, it also comes with an X Window server which is used to run graphical Linux programs that display their output on your Windows computer.  I use this most often to run GNU emacs, an awesomely powerful text editor.  I can edit files directly on the Linux servers but the editor itself is displayed on my Windows workstation.

One problem with the X Window server is that I have to remember to manually start it every time I log on to Windows.  The obvious solution to this is to create a shortcut to the X server in the Startup group.  This works great, with two problems:

  1. You have to modify the system PATH variable to include the X server directory: /usr/X11R6/bin, and
  2. An annoying text window pops up with the output of the X server. 

The text window is an attractive nuisance: I find myself wanting to close it because it's always in my way (even when minimized), but if I close it then the X server and all of my open X display windows are unceremoniously closed.

The solution is the Cygwin run command.  It is used to launch command line programs without opening a text window.  Because it is a "windowed" program (like Excel), not a command line program (like cmd.exe), it doesn't open up a text window.  Not only that, but it takes a parameter for a directory that's added to the system PATH variable before it executes its argument.  It solves both of my problems!

To start the cygwin X server, create a new shortcut in your Startup group.  It should execute this command:

<path-to-cygwin>\bin\run.exe -p /usr/X11R6/bin XWin -multiwindow -clipboard -silent-dup-error
For my setup, where I have cygwin installed in c:\opt\cygwin, the entire command is:
C:\opt\cygwin\bin\run.exe -p /usr/X11R6/bin XWin -multiwindow -clipboard -silent-dup-error

Now, whenever I log in to Windows, the X server automatically starts, and I don't have any annoying text windows that I might accidentally close.

If you enjoyed this article, we invite you to learn more about how you can become a high achieving computer professional.

Document Actions
« February 2017 »