cdesktopenv/cde/programs/dtlogin/config/Xsession.src

603 lines
17 KiB
Plaintext

XCOMM! KORNSHELL
XCOMM ##########################################################################
XCOMM
XCOMM Xsession
XCOMM
XCOMM Common Desktop Environment (CDE)
XCOMM
XCOMM Configuration script for the Login Manager
XCOMM
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
XCOMM (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
XCOMM (c) Copyright 1993,1994,1996 International Business Machines Corp.
XCOMM (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
XCOMM (c) Copyright 1993,1994,1996 Novell, Inc.
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
XCOMM (c) Copyright 1996 Hitachi.
XCOMM
XCOMM ************** DO NOT EDIT THIS FILE **************
XCOMM
XCOMM CDE_INSTALLATION_TOP/bin/Xsession is a factory-default file and will
XCOMM be unconditionally overwritten upon subsequent installation.
XCOMM Modification is discouraged.
XCOMM
XCOMM $TOG: Xsession.src /main/19 1999/03/30 09:38:50 mgreess $
XCOMM
XCOMM Usage: $0 [-session session_name]
XCOMM
XCOMM ##########################################################################
#define HASH #
#ifdef sun
HASH
HASH Set OPENWINHOME
HASH
if [ -z "$OPENWINHOME" ]
then
export OPENWINHOME="/usr/openwin"
fi
#endif
#if 0
/*
* Platform specific definitions
*
* cpp_XINITUSER - user's xinit startup file
* cpp_MAIL - system mail file
* cpp_HELLO - dthello command line
* cpp_XDMSYS - xdm system session file
*/
#endif
#if defined (_AIX)
# define cpp_XINITUSER "$HOME/.xinitrc"
# define cpp_MAIL "/var/spool/mail/$USER"
#elif defined (__hpux)
# define cpp_XDMSYS "/usr/lib/X11/xdm/sys.xsession"
#elif defined (sun)
# define cpp_XINITUSER "$HOME/.xinitrc"
# define cpp_MAIL "/var/mail/$USER"
# undef cpp_HELLO
# define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
#endif
#if defined (__hpux) && defined (BLS)
# undef cpp_HELLO
# define cpp_HELLO "$DT_BINPATH/dthello -file /etc/copyright -file $HOME/.dtlogininfo &"
#endif
#ifdef linux
# define cpp_MAIL "/var/mail/$USER"
# define cpp_XDIR "/usr/bin"
# define cpp_XINITUSER "$HOME/.xinitrc"
# define cpp_XDMSYS "/etc/X11/Xsession"
# undef cpp_HELLO
# define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
#endif
#ifdef __FreeBSD__
# define cpp_MAIL "/var/mail/$USER"
# define cpp_XINITUSER "$HOME/.xinitrc"
# define cpp_XDMSYS "/usr/local/lib/X11/xdm/Xsession"
# undef cpp_HELLO
# define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
#endif
#ifdef __OpenBSD__
# define cpp_MAIL "/var/mail/$USER"
# define cpp_XINITUSER "$HOME/.xinitrc"
# define cpp_XDMSYS "/etc/X11/xdm/Xsession"
# undef cpp_HELLO
# define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
#endif
#ifdef __NetBSD__
# define cpp_MAIL "/var/mail/$USER"
# define cpp_XINITUSER "$HOME/.xinitrc"
# define cpp_XDMSYS "/etc/X11/xdm/Xsession"
# undef cpp_HELLO
# define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
#endif
#if 0
/*
* Fallback definitions
*/
#endif
#if !defined (cpp_XINITUSER)
# define cpp_XINITUSER "$HOME/.x11start"
#endif
#if !defined (cpp_MAIL)
# define cpp_MAIL "/var/mail/$USER"
#endif
#if !defined (cpp_HELLO)
# define cpp_HELLO "$DT_BINPATH/dthello &"
#endif
#if !defined (cpp_XDMSYS)
# define cpp_XDMSYS "/usr/lib/X11/xdm/Xsession"
#endif
XCOMM ##########################################################################
XCOMM
XCOMM
XCOMM This script starts the user's session. It searches for one of three
XCOMM types of startup mechanisms, in the following order:
XCOMM
XCOMM DT existence of CDE DT Session Manager on the system
XCOMM XDM "$HOME/.xsession" (executable)
XCOMM xinit cpp_XINITUSER (executable)
XCOMM
XCOMM If none of these startup mechanisms exist, a default window manager
XCOMM and terminal emulator client are started.
XCOMM
XCOMM ##########################################################################
XCOMM
XCOMM Variables must be explicitly exported
XCOMM
set +a
XCOMM ##########################################################################
XCOMM
XCOMM Initialize session startup logging
XCOMM
XCOMM ##########################################################################
exec >/dev/null 2>/dev/null
LOGDIR=$HOME/.dt
LOGFILENAME=$LOGDIR/startlog
MSGLOGFILENAME=$LOGDIR/errorlog
if [ ! -d $LOGDIR ]; then
mkdir $LOGDIR
if [ -d $LOGDIR ]; then
chmod 755 $LOGDIR
fi
fi
[ -f $LOGFILENAME.older ] && rm -f $LOGFILENAME.older
[ -f $LOGFILENAME.old ] && mv -f $LOGFILENAME.old $LOGFILENAME.older
[ -f $LOGFILENAME ] && mv -f $LOGFILENAME $LOGFILENAME.old
touch $LOGFILENAME
[ ! -f $MSGLOGFILENAME ] && touch $MSGLOGFILENAME
if [ -w $LOGFILENAME ]; then
exec >>$LOGFILENAME 2>&1
fi
Log()
{
echo "--- $1" >>$LOGFILENAME 2>&1
}
Log "$(date)"
Log "$0 starting..."
XCOMM ##########################################################################
XCOMM
XCOMM Global environment section
XCOMM
XCOMM DT pre-sets the following environment variables for each user.
XCOMM
XCOMM (internal)
XCOMM
XCOMM DISPLAY set to the value of the first field in the Xservers file.
XCOMM HOME set to the user's home directory (from /etc/passwd)
XCOMM LANG set to the display's current NLS language (if any)
XCOMM LC_ALL set to the value of $LANG
XCOMM LOGNAME set to the user name
XCOMM PATH set to the value of the Dtlogin "userPath" resource
XCOMM USER set to the user name
XCOMM SHELL set to the user's default shell (from /etc/passwd)
XCOMM TZ set to the value of the Dtlogin "timeZone" resource
XCOMM
XCOMM
XCOMM (Xsession)
XCOMM
XCOMM TERM set to xterm
XCOMM EDITOR set to the default editor
XCOMM KBD_LANG set to the value of $LANG for certain languages
XCOMM MAIL set to cpp_MAIL
XCOMM
XCOMM
XCOMM Three methods are available to modify or add to this list depending
XCOMM on the desired scope of the resulting environment variable.
XCOMM
XCOMM 1. X server and/or all users on a display (Xconfig file)
XCOMM 2. all users on a display (Xsession file)
XCOMM 3. individual users (.dtprofile file)
XCOMM
XCOMM See DT on-line help, the DT Users Guide, or the Dtlogin(1X) man
XCOMM page for details on setting environment variables.
XCOMM
XCOMM
XCOMM ##########################################################################
[ -z "$EDITOR" ] && EDITOR=CDE_INSTALLATION_TOP/bin/dtpad
[ -z "$MAIL" ] && MAIL=cpp_MAIL
[ -z "$LANG" ] && LANG="C"
TERM=dtterm
SESSION_SVR=`hostname`
export PATH EDITOR MAIL TERM SESSION_SVR LANG
#if defined (_AIX) && defined (AIXV4)
XCOMM
XCOMM Clear the LFT message locale override if set
XCOMM
if [ "$LC_MESSAGES" = "C@lft" ]
then
unset LC_MESSAGES
fi
#endif
#if defined (__hpux)
HASH
HASH Set the keyboard language if necessary...
HASH
if [ ! -z "$LANG" ]
then
case $LANG in
bulgarian | czech | hebrew | hungarian | \
japanese | korean | polish | rumanian | \
russian | serbocroatian)
KBD_LANG=$LANG
export KBD_LANG;;
chinese-t) KBD_LANG=t_chinese
export KBD_LANG;;
chinese-s) KBD_LANG=s_chinese
export KBD_LANG;;
*);;
esac
fi
#endif
HASH
HASH Locate configuration file directories
HASH
XDIR=XPROJECTROOT/bin
DT_BINPATH=CDE_INSTALLATION_TOP/bin
DT_INSTALL=CDE_INSTALLATION_TOP
DT_INSTALL_CONFIG=CDE_INSTALLATION_TOP/config
DT_CONFIG=CDE_CONFIGURATION_TOP/config
DT_CONFIG_PATH="$DT_INSTALL_CONFIG $DT_CONFIG"
XCOMM ##########################################################################
XCOMM
XCOMM Default desktop component configuration variable settings
XCOMM
XCOMM This section sets the default value for variables controlling
XCOMM some desktop components.
XCOMM
XCOMM ##########################################################################
HASH
HASH Input method server startup
HASH
if [ -z "$DTSTARTIMS" ]; then
DTSTARTIMS=True
fi
if [ "$DTSTARTIMS" = "False" ]; then
unset DTSTARTIMS
fi
HASH
HASH Default desktop screen saver action list
HASH
export DTSCREENSAVERLIST="StartDtscreenSwarm StartDtscreenQix \
StartDtscreenFlame StartDtscreenHop StartDtscreenImage StartDtscreenLife \
StartDtscreenRotor StartDtscreenPyro StartDtscreenWorm StartDtscreenBlank"
HASH
HASH Session startup clients and args
HASH
if [ "$SESSIONTYPE" = "altDt" ]; then
dtstart_session[0]="$SDT_ALT_SESSION"
dtstart_hello[0]="$SDT_ALT_HELLO"
else
DTSESSION_ARGS=""
if [ $# -ge 2 ]; then
if [ "$1" = "-session" ]; then
DTSESSION_ARGS="$1 $2"
fi
fi
dtstart_session[0]="$DT_BINPATH/dtsession $DTSESSION_ARGS"
dtstart_hello[0]=cpp_HELLO
fi
dtstart_session[1]="$HOME/.xsession"
dtstart_session[2]=cpp_XINITUSER
dtstart_session[3]="$XDIR/xterm -geometry 80x24+10+10"
dtstart_hello[1]="$XDIR/xsetroot -default &"
dtstart_searchpath="$DT_BINPATH/dtsearchpath -ksh"
dtstart_ttsession="$DT_BINPATH/ttsession -s"
dtstart_dtdbcache="$DT_BINPATH/dtdbcache -init"
HASH
HASH dtdbcache file's directory should match
HASH _DTDTSMMTEMPDIR in DtSvc/DtUtil1/DtsMM.h
HASH
dtdbcacherm="rm -f /tmp/dtdbcache_$DISPLAY"
dtstart_appgather="$DT_BINPATH/dtappgather &"
#if defined(sun)
dtstart_dsdm="$DT_BINPATH/dsdm &"
#endif
xdmstart_session[0]="$HOME/.xsession"
xdmstart_session[1]=cpp_XDMSYS
xdmstart_session[2]="xterm -geometry 80x24+10+10 -ls"
xdmstart_hello="$XDIR/xsetroot -default &"
SESSIONLOGDIR=$LOGDIR/sessionlogs
SESSIONLOGFILENAME="$SESSIONLOGDIR/$SESSION_SVR"_DISPLAY=$DISPLAY
if [ ! -d $SESSIONLOGDIR ]; then
mkdir $SESSIONLOGDIR
if [ -d $SESSIONLOGDIR ]; then
chmod 755 $SESSIONLOGDIR
fi
fi
touch $SESSIONLOGFILENAME
if [ -w $SESSIONLOGFILENAME ]; then
dtstart_sessionlogfile="$SESSIONLOGFILENAME"
else
dtstart_sessionlogfile="/dev/null"
fi
rm -f $SESSIONLOGFILENAME
#ifdef sun
if [ "$DTXSERVERLOCATION" != "remote" ]
then
HASH
HASH Start fallback console
HASH
if [ -x $XDIR/fbconsole ]
then
$XDIR/fbconsole &
fi
fi
#endif
#define cpp_Xsession
#include "_common.ksh.src"
#undef cpp_Xsession
XCOMM ##########################################################################
XCOMM
XCOMM Source user's desktop profile
XCOMM
XCOMM This section determines if the user has a desktop profile in their
XCOMM home directory. If not, the desktop default profile is copied to
XCOMM the home directory. The desktop profile is then sourced. The purpose
XCOMM is to incorporate any per-user/per-session environment customizations
XCOMM and thereby propagate them to applications and desktop components.
XCOMM
XCOMM ##########################################################################
DTSYSPROFILE=sys.dtprofile
DTPROFILE=.dtprofile
if [ ! -f $HOME/$DTPROFILE ]; then
for i in $DT_CONFIG_PATH
do
if [ -f $i/$DTSYSPROFILE ]; then
/usr/bin/awk '
BEGIN {printit=1}
/SYSPROFILE COMMENT START/ {printit=0; next}
/SYSPROFILE COMMENT END/ {printit=1; next}
printit==1 {print}' <$i/$DTSYSPROFILE >$HOME/$DTPROFILE
/bin/chmod 755 $HOME/$DTPROFILE
break
fi
done
fi
HASH
HASH source the .dtprofile.
HASH
if [ -f $HOME/$DTPROFILE ]; then
dtprofile_errors=`KORNSHELL -n $HOME/$DTPROFILE 2>&1`
if [ "0" = "$?" ]; then
Log "sourcing $HOME/$DTPROFILE..."
. $HOME/$DTPROFILE
else
Log "not sourcing $HOME/$DTPROFILE due to errors..."
Log "$dtprofile_errors"
fi
fi
XCOMM ##########################################################################
XCOMM
XCOMM External Xsession processing section
XCOMM
XCOMM This section searches the Xsession.d subdirectory and sources
XCOMM the files contained therein. The purpose is to set up any
XCOMM per-user/per-session environment customizations and thereby propagate
XCOMM them to applications and desktop components.
XCOMM
XCOMM ##########################################################################
DT_XSESSION_DIR=Xsession.d
for i in $DT_CONFIG_PATH
do
if [[ -d $i/$DT_XSESSION_DIR ]]; then
HASH
HASH Run custom Xsession scripts for this session.
HASH
for SCRIPT in $(ls $i/$DT_XSESSION_DIR); do
if [ -x $i/$DT_XSESSION_DIR/$SCRIPT -a \
\( ! -d $i/$DT_XSESSION_DIR/$SCRIPT \) ]; then
Log "sourcing $i/$DT_XSESSION_DIR/$SCRIPT..."
. $i/$DT_XSESSION_DIR/$SCRIPT
fi
done
fi
done
XCOMM ##########################################################################
XCOMM
XCOMM Startup section.
XCOMM
XCOMM Note: The ksh syntax ${parameter%% *} is used when appropriate to
XCOMM remove any command line options that may have been included
XCOMM in the definition of a DT executable below.
XCOMM
XCOMM ##########################################################################
XCOMM
XCOMM Return first command in array named by $1 that is executable
XCOMM
GetFirst()
{
let i=0
while true; do
eval "cmd=\${$1[$i]}"
[ -z "$cmd" ] && break
[ -x "${cmd%% *}" ] && echo "$cmd" && break
Log "could not start $cmd"
let i=$i+1
done
}
XCOMM
XCOMM Start first command in array named by $1 that is executable. If
XCOMM $2 is 'eval', command result will be 'eval'ed.
XCOMM
StartFirst()
{
first=$(GetFirst $1)
if [ ! -z "$first" ]; then
Log "starting $first"
if [ "$2" = "eval" ]; then
eval `eval "PATH=$DT_BINPATH:$PATH $first"`
else
eval "PATH=$DT_BINPATH:$PATH $first"
fi
fi
}
HASH
HASH Prepare for session startup
HASH
if [ "$DTSOURCEPROFILE" = "true" ]
then
case ${SHELL##*/} in
sh | ksh | ksh93 | dtksh) shellprofile="$HOME/.profile";;
bash) shellprofile="$HOME/.bash_profile";;
csh | tcsh) shellprofile="$HOME/.login";;
*) Log "non-standard shell $SHELL"
esac
fi
if [ "$shellprofile" -a ! -f "$shellprofile" ]
then
Log "could not read $shellprofile"
unset shellprofile
fi
if [ "$SESSIONTYPE" = "xdm" ]; then
startup=$(GetFirst xdmstart_session) # get xdm session client
StartFirst xdmstart_hello # start xdm hello client
else
startup=$(GetFirst dtstart_session) # get desktop session client
StartFirst dtstart_hello # start desktop hello client
StartFirst dtstart_searchpath eval # setup desktop search paths
tooltalk=$(GetFirst dtstart_ttsession) # get tooltalk client
dtdbcache=$(GetFirst dtstart_dtdbcache) # get dtdbcache client
#if defined(sun)
if [ -z "$SDT_NO_DSDM" ]; then
StartFirst dtstart_dsdm # start drag and drop proxy
fi
#endif
StartFirst dtstart_appgather # setup session applications
fi
HASH
HASH Start the session.
HASH
if [ $shellprofile ]; then
Log "execing $startup using $shellprofile..."
case ${SHELL##*/} in
sh | bash | ksh | ksh93 | dtksh)
dotprofile_errors=`$SHELL -n $shellprofile 2>&1`
if [ "0" = "$?" ]; then
source_profile=". $shellprofile"
source_login="source $shellprofile"
else
Log "parse errors found in $shellprofile..."
Log "$dotprofile_errors"
source_profile="echo 'not execing $shellprofile due to errors'"
source_login="echo 'not execing $shellprofile due to errors'"
fi;;
*)
source_profile=". $shellprofile"
source_login="source $shellprofile";;
esac
else
Log "execing $startup..."
source_profile="echo 'not execing $HOME/.profile (see $HOME/.dtprofile)'"
source_login="echo 'not execing $HOME/.login (see $HOME/.dtprofile)'"
fi
if [ -z "$dtdbcache" ]; then
dtdbcache="echo could not start $dtstart_dtdbcache"
fi
export DT=true;
case ${SHELL##*/} in
sh | bash) $SHELL -c "$source_profile; \
unset DT; \
$dtdbcache; \
PATH=$DT_BINPATH:\$PATH $tooltalk; \
$startup > $dtstart_sessionlogfile 2>&1" ;;
ksh | ksh93 | dtksh) $SHELL -c "$source_profile; \
unset DT; \
$dtdbcache; \
PATH=$DT_BINPATH:\$PATH $tooltalk;\
$startup >| $dtstart_sessionlogfile 2>&1" ;;
csh | tcsh) $SHELL -c "unsetenv _ PWD; \
$source_login; \
unsetenv DT; \
$dtdbcache; \
(set path = ( $DT_BINPATH \$path ); $tooltalk ); \
$startup >&! $dtstart_sessionlogfile" ;;
*) unset DT
$dtdbcache
StartFirst dtstart_ttsession
$startup >| $dtstart_sessionlogfile 2>&1 ;;
esac
$dtdbcacherm # remove the actions/datatypes cachefile
XCOMM #################### eof #################################