[comp.windows.x] DISPLAY shell variable

rw@SUNAPEE.DARTMOUTH.EDU (Randy Witlicki) (09/28/90)

  We have some DEC VT1200 X terminals.  We use them to log into
SUN and DECstation UNIX boxes.  When you use them with a
window manager you have to set the DISPLAY variable to
machinename:0  so twm (or whatever) knows where to go.
  Has anyone come up with a good script or program to do this
while checking to see where you are?  e.g. - set DISPLAY to
hostname or remote X terminal name.

  Something on the order of :

  DISPLAY=`who am i | awk '{ print substr($6,2,length($6)-2) }'`:0
  if [ $DISPLAY = "unix:0.0" ]    # figure out if we're remote or not
  ### also check for null string, ":0.0", etc.
  then
	  DISPLAY=`hostname`

  This is some first pass hackery at the problem which will probably fail
in lots of cases.  There is also the pathological case where someone is
logged in from two machines away.

  Has anyone solved this?  Am I missing something obvious?

  While I'm at it - any way to prevent someone who is telneted into a
machine from running xinit and blowing away the guy at the console?

  - Randy Witlicki   Math & CS Department    Dartmouth College
      rw@sunapee.dartmouth.edu