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

There are other situations where the port in question is not so easily computed; these usually relate to tunneling of some sort, such as with (ssh -X) commands.

Not really, just use the $ENV{DISPLAY} like always. Add 6000 to the display number like always. No special action is required for this.