No, you can have $DISPLAY set and not have X running. I've seen $DISPLAY set by login scripts before (not uncommon when the display is on a remote machine). Try this from a text console without X running:
bash$ export DISPLAY=localhost:0
bash$ echo $DISPLAY
Remember, your X server may not be on the local machine. I keep my $DISPLAY variable set on my embedded machines so I can run X programs on them at will, but don't actually start window managers for them, so most of the time $DISPLAY is set but the server might or might not be available.
Also, you can have X running but not have a $DISPLAY environment variable set (like if you go to a text console on the same machine).
This brings up the question of "what do you mean 'X running'?". Do you mean: is there one or more X servers going on this or some other machine, or is this program being run from within an X session? These are both tricky. My program just looks for a running X server at either $DISPLAY or localhost:0; if a server is not available, it returns 0.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.