This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Running a simple GUI app


John Emmas wrote on Monday, August 18, 2008 4:55 PM::

> Hi there,
> 
> After installing Cygwin (under WinXP) I've got to the stage of
> compiling a very simple "Hello World" app which just displays an
> empty GTK dialog with the title "Hello World".  To run the app I
> (currently) have to start Cygwin (using its desktop icon), type
> "startx" into the DOS terminal (which opens a second terminal
> window), navigate to the folder containing my executable and finally
> type "./HelloWorld".  Obviously this is all a bit convoluted.  Is
> there a simpler way to launch my app - for example:- 
> 
> a)  Double clicking on an icon, or
> b)  Issuing some command (from a DOS terminal) that would launch the
> app - but starting Cygwin and X invisibly.
> 
> Thanks,
> 
> John

First, there's no such concept as "starting Cygwin".  Cygwin is just
a DLL.  If you mean "start a bash session", there's no need to do
that just to run an X program.


You could* write a bash script along the lines of:

-------- /path/to/runyourprog -------
#!/bin/bash --login

checkx || startx
exec yourprogname
-------------------------------------

The --login should ensure that the environment is set up correctly.

Then you can create a shortcut with a target of:

C:\cygwin\bin\bash -c /path/to/runyourprog


* This is very much a lame Windows-user type of thing to be doing.
Xwin is a SERVER.  It should not be started by running a client.  
If you were to ask a linux mailing list for a way to switch runlevel
if someone tried to run your program without an X server, you would 
rightly expect the electronic equivalent of howls of derision.

Why do you not just start X when you log on?  If you'd rather not 
start X every time you log on, you only need to start it the first 
time you try to run an X program.  Any properly written X program 
(including yours) should tell the user if it cannot connect to the 
X server, so if you get this message, you just need to run the 
server - once, then try again.

Phil

-- 
This email has been scanned by Ascribe PLC using Microsoft Antigen for Exchange.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]