Use X11 apps from a Windows CMD window

Here’s a thing.

Use Cygwin’s X11 apps from a Windows CMD window.

First, the XWin sever is running. I always install the XDG stuff, which means I have the XDG menu in my taskbar menu. If I hover over it, the hover info will show that it is running on display :0.

At the very end of my Windows PATH, I have the cygwin64 bin folder (and any other folders I want to use); I have a userspace installation, so in my case that is

C:\Users\username\installs\cygwin64\bin

But usually it is

C:\cygwin64\bin

Then I create an environment variable in my Windows environment.

DISPLAY=:0

I can check it is defined once I open the CMD window:

C:\Users\username>set | grep DIS
DISPLAY=:0

Then I can open a Windows CMD.EXE window and run my Cygwin applications, even the graphical ones.

I guess this is obvious to some, but I found it a useful thing.

Now, of course CMD doe not understand & as backgrounding the process, so you do not have the CMD prompt while the program is running. If this is not OK, what do you do? Use the Windows START command:

start /b xcalc

will run xcalc in the background and give you back the prompt. Obviously, if you want to regularly run these X11 programs from CMD, you could make a batch file that issues the START command and put it somewhere that CMD will find it.

Anyway, I think that’s nifty.

Author: Darren

I'm a scientist by training, currently working as a writer, trainer and editor.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.