Checking for X availability

Cameron Laird claird at lairds.us
Sun Jan 16 11:08:03 EST 2005


In article <mailman.508.1105443600.22381.python-list at python.org>,
Nils Nordman  <nino at nordman.org> wrote:
>On Tue, Jan 11, 2005 at 03:32:01AM -0800, Flavio codeco coelho wrote:
>> So my question is: how can I check for the availability of X? i.e.,
>> How will my program know if its running in a text only console or in
>> console window over X?
>
>Well, one way to do it is to check whether the environment variable
>DISPLAY is set (which it is when running under X, and should not be
>otherwise).
			.
			.
			.
While there certainly are successful programs that use this
approach, it's NOT true in general--at least in the generality
I encounter.  It can happen, for example, that a user withOUT
$DISPLAY in the environment launches

  interesting_application -display SOME_DISPLAY ...

Jeremy Bowers gives excellent advice elsewhere in this thread:
try, and use exceptions to learn what's going on; as you learn
more, relaunch the application with a refined command-line.



More information about the Python-list mailing list