http://www.perlmonks.org?node_id=433186


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

So can you not check for BOTH a non-empty DISPLAY *and* check the process table (via ps or whatever is handy) for the X process?