Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!ucsd!ucbvax!bloom-beacon!dont-send-mail-to-path-lines From: mouse@larry.mcrcim.mcgill.EDU Newsgroups: comp.windows.x Subject: Re: UNIX/X-windows questions Message-ID: <9101241238.AA17111@Larry.McRCIM.McGill.EDU> Date: 24 Jan 91 12:38:51 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 23 >>> Is there a call to see if we are in X? >> if (!strcmp("xterm",getenv("TERM"))) Or mterm, or aixterm, or sun, or any of the many other possible values of $TERM when running under X.... > The best way is to try to open the display XOpenDisplay(":0.0"). Except that you may be in X, but the server may not be on the machine you're trying to run the program on. I would say that if -display is on the command line, use it. Otherwise check for DISPLAY in the environment, and if set, use it; otherwise, assume X is not available. This also allows the user to avoid using X even when available, by unsetting DISPLAY in the environment. (Yes, this is sometimes desirable.) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu