[rescue] Auto display setup

Greg A. Woods rescue at sunhelp.org
Sun Aug 19 12:21:40 CDT 2001


[ On Sunday, August 19, 2001 at 11:26:01 (-0500), Eric Hall wrote: ]
> Subject: [rescue] Auto display setup
>
> I'd like to automate my $DISPLAY variable. Something like
> this in my .profile?
> 
> if [ $LOGINHOST = remote ] then
> 	DISPLAY=$LOGINHOST:0
> 	export DISPLAY
> fi
> 
> Can anyone point me to an example on how to do this?

You probably don't want to do it in your .profile.  It will be set
properly by the likes of rlogin/slogin/telnet.

You may want to do it in your .xinitrc (or .xsession).  Here are the
relevant lines from mine:

# first source the relevant profiles to make sure $HOSTNAME and
# $DOMAINNAME are set....
#
if [ -r /etc/profile ] ; then
        . /etc/profile < /dev/null
else
        echo "$argv0: no /etc/profile on this host!"
fi
if [ -r $HOME/.profile ] ; then
        . $HOME/.profile < /dev/null
else
        echo "$argv0: no $HOME/.profile on this host!"
fi

XODISPLAY=$DISPLAY
echo "$argv0: starting up with DISPLAY='$DISPLAY'"

if [ $argv0 = ".xsession" -a -z "$XDMHOST" ] ; then
        # assume HOSTNAME & DOMAINNAME are set by profile(s)
        XDMHOST="${HOSTNAME}${DOMAINNAME}"
        export XDMHOST                                  # also used by .twmrc
        echo "$argv0: have set XDMHOST='$XDMHOST'"
fi

ONCONSOLE=false; export ONCONSOLE
case "$DISPLAY" in
":0"|":0.0"|"")
        # don't bother with this unless it'll do us some good...
        if [ -w /dev/console ] ; then
                ONCONSOLE=true; export ONCONSOLE
                echo "$argv0: redirecting stdout and stderr to /dev/console."
                exec 1>/dev/console 2>&1
        else
                echo "$argv0: WARNING: display was '$DISPLAY' but /dev/console not writable by $USER!"
                ls -l /dev/console
        fi
        DISPLAY="${XDMHOST:-${HOSTNAME}${DOMAINNAME}}:0"
        echo "$argv0: have set DISPLAY='$DISPLAY'"
        ;;
esac
if [ "$XODISPLAY" != "$DISPLAY" ] ; then
        echo "$argv0: adjusted DISPLAY='$DISPLAY'"
fi
unset XODISPLAY
export DISPLAY

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods at acm.org>     <woods at robohack.ca>
Planix, Inc. <woods at planix.com>;   Secrets of the Weird <woods at weird.com>



More information about the rescue mailing list