Civileme wrote:
> 
> Necrotica wrote:
> >
> > I'm interested in learning a little about bash scripting. In particular, I'd
> > like to learn how to tell if the user logging on is logging in under X or from
> > a command prompt. Can anyone point me in the direction of where I can find this
> > information? Thanks...
> >
> > -Chris
> 
> printenv from Konsole when you are logged in in graphics mode
> 
> printenv from a console (logged in on runlevel 3)
> 
> Check the settings of the DISPLAY variable
> 
> Civileme

Ummm...  Well under the console perhaps better to printenv |
less  (blush).  That fills more than a screen!


The point is DISPLAY has a value in graphics mode and does NOT
exist in console

So 

if [ $DISPLAY ] then
        # DISPLAY is set and is a nonzero length string so do GUI stuff
elif [ -z $DISPLAY ]
        #  do the console stuf here  (length of string is zero)
else
        #  do any other stuff here
fi

Civileme

Reply via email to