Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!asuvax!mcdphx!behemoth!razdan From: razdan@phx.mcd.mot.com (Anshuman Razdan) Newsgroups: comp.windows.x Subject: Re: UNIX/X-windows questions Message-ID: Date: 21 Jan 91 15:10:31 GMT References: <139@bwilab3.UUCP> <1441@rascal.UUCP> <1991Jan18.075159.26771@eng.umd.edu> Sender: listen@mcdphx.phx.mcd.mot.com Organization: Motorola MCD Lines: 49 In-reply-to: stripes@eng.umd.edu's message of 18 Jan 91 07:51:59 GMT In article <1991Jan18.075159.26771@eng.umd.edu> stripes@eng.umd.edu (Joshua Osborne) writes: In article <1441@rascal.UUCP>, theo@rascal.UUCP (T. Kramer) writes: > In article <139@bwilab3.UUCP> chris@bwilab3.UUCP (Chris Curtin) writes: > > > > > >I have two simple questions, both of which deal with X windows. (One has > >to do with UNIX enviornment variables, so the cross post). > > > >Now the X question: > > > >Is there a call to see if we are in X? I would rather not do a simple call > >and see if it fails since this is a hack and doesn't look too good. > > > How about setting an environment variable eg. TERM=xterm for the X logins > and TERM=vt100 for character based terminal logins. You of course have to > know which tty lines support X terminals and which do not. > > Then using the following on startup > > if (!strcmp("xterm",getenv("TERM"))) > XtInitialise(); /* Xt Intrinsic call */ > else > initscr(); /* Curses call */ In my XView shelltool window my TERM variable is sun-cmd, not xterm. If I start X by "logging-in" from xdm my TERM variable will not be set for programs my window manager starts for me, or my .xsession script starts, and that's most all of the X I run form day to day. Users of dxterm may be using anything from vt52 to vt340 for TERM. Besides you missed my common setting for TERM: xterms-notite (Small [25x80] xterm with no tite [page flipping]). -- stripes@eng.umd.edu "Security for Unix is like ------------------------- ------------------------- Am I missing something or ..... Couldn't this be done by just trying to do a XOpenDisplay and if this returns NULL or error (whatever the case may be) you are not in X and should assume for all purposes not to do any X related stuff. -- Anshuman Razdan ************************************************************ * razdan@toy Test and Methodology Group * * * * razdan@phx.mcd.mot.com Diablo Plant, Tempe Az * ************************************************************