[Gllug] Detecting X in cshrc

Juan AMIGUET K995263 at atlas.kingston.ac.uk
Wed Apr 30 09:45:02 UTC 2003


Regarding Re: [Gllug] Detecting X in cshrc  Tethys Wrote on 29 Apr 2003, at 19:21:

> 
> Ian Norton writes:
> 
> >you could just see if the DISPLAY variable is defined?
> 
> No, no, no! I've lost count of the number of apps that do this,
> and it's just plain wrong. The *only* way to see if you're in
> X is to try connecting to the X server in $DISPLAY. It's quite
> possible (and indeed in some cases, common) for it to be set,
> but either not pointing to a valid X server, or pointing to
> one that you don't have permissions to access.
> 
>  xdpyinfo > /dev/null 2>&1
>  if [ $? -eq 0 ]
>  then
>   echo "I'm running under X. Launch GUI app."
>  else
>   echo "I'm stuck on a console. Use the curses interface.
>  fi
> 
> But that doesn't seem to be what the original question was asking. If
> you're in an xterm, then your $TERM is whatever you've either set it
> to in your startup scripts, or inherited from the xterm itself
> (usually just "xterm", but can be overriden with the -tn command line
> switch).
> 
> What's the problem that you're trying to solve here? Why do you
> want to override the default $TERM?

Its just so that I can use vi and I do not have weird characters 
appearing. 
so to choose automatically between xterm-color and vt100-color
xterm when the shell starts under x and vt100 when I am in normal 
console

I will try detecting throught the X lock file.
Cheers.

> 
> Tet
> 
> 
> -- 
> Gllug mailing list  -  Gllug at linux.co.uk
> http://list.ftech.net/mailman/listinfo/gllug


-----------------------------------
Juan Amiguet Vercher
Where is my mind?


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list