Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cornell!uw-beaver!ubc-cs!alberta!myrias!brb From: brb@myrias.com (Brian Baird) Newsgroups: comp.windows.x Subject: Re: automatically setting DISPLAY variable Message-ID: Date: 26 Aug 90 03:36:50 GMT References: <9008242049.AA12394@bach.cs.byu.edu> Organization: Myrias Research, Edmonton Lines: 45 Thomas McNeill provides a Csh script, C program combination to set the DISPLAY environment variable from a Csh .login. Unfortunately, the directions are incorrect. DISPLAY will be set for the "setdisplay" script, but not for the parent shell. Here's my (somewhat simpler) version. : sh this file echo >whatdisplay <<\EOF #! /bin/sh # whatdisplay: which X display am I running from? # # 90 08 25 Brian Baird, Myrias Research, Edmonton # # # Make this script executable, place it in some directory in your # PATH, and, depending on your shell, add the following line to the # named file on each machine you rlogin to. This script doesn't # handle nested rlogins. # # Shell File Line # ----- ---- ---- # csh .login setenv DISPLAY `whatdisplay` # sh .profile DISPLAY=`whatdisplay`; export DISPLAY # bash .bash_login export DISPLAY=`whatdisplay` case $DISPLAY in "") ;; *) echo "$DISPLAY" # display already set exit 0 ;; esac HOST=`who am i | sed 's/.*(\(.*\)).*/\1/'` case "$HOST" in "") echo ":0" ;; # local host *:*) echo "$HOST" ;; # remote host includes display *) echo "$HOST:0" ;; # simple remote host esac EOF exit -- Brian Baird brb@myrias.com Myrias Research, Edmonton {uunet,alberta}!myrias!brb