Path: utzoo!utgpu!news-server.csri.toronto.edu!dgp.toronto.edu!flaps Newsgroups: comp.windows.x From: flaps@dgp.toronto.edu (Alan J Rosenthal) Subject: Re: Ways to detect what window system is running. Message-ID: <1991Apr17.085930.4948@jarvis.csri.toronto.edu> References: <963@epiwrl.UUCP> Date: 17 Apr 91 12:59:30 GMT Lines: 24 nelson@wrl.epi.com (Ken Nelson) writes: >I am looking for scripts or ideas for how to detect what >window system is running. We need to run different versions of >the same program when under X Windows or SunView. You could always just put only the correct one in people's paths. The startup script for the window system can add something to their path, or something like that. Alternatively, you could go with the semi-standard of calling them "xmyprog" and "myprog". If you want to write a shellscript to detect this, in this particular case you could use the $TERM variable, i.e. the shellscript would run something like /dist/$TERM/myprog. Generally speaking, for most systems like that, there is some sort of initialization sequence all programs have to go through, and it fails if the window system isn't running. Therefore you can write a program which works under both by attempting to use one window system and then the other. [I've never done this personally, although I have written programs which use either the window system or the terminal emulator.] Or in this particular case, you could do a getenv("TERM") and see if it's "sun" or "xterm". I think I prefer the separate binaries, though, personally. ajr