in reply to Re: How to detect X?
in thread How to detect X?

That would not be very reliable. DISPLAY isn't always set, even if an X server is available. And while you shouldn't, it's not uncommon for an 'DISPLAY=...' line to be found in a .profile (usually because the GUI setup doesn't set DISPLAY properly) - my .profile had such a line for a long time.

Probably the best way is to just try to launch the GUI version of the application. If it works, it works, if it doesn't, nothing is displayed and you fall back on the non GUI version.