2 XCOMM ##########################################################################
6 XCOMM Common Desktop Environment (CDE)
8 XCOMM Configuration script for the Login Manager
10 XCOMM (c) Copyright 1996 Digital Equipment Corporation.
11 XCOMM (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
12 XCOMM (c) Copyright 1993,1994,1996 International Business Machines Corp.
13 XCOMM (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
14 XCOMM (c) Copyright 1993,1994,1996 Novell, Inc.
15 XCOMM (c) Copyright 1996 FUJITSU LIMITED.
16 XCOMM (c) Copyright 1996 Hitachi.
18 XCOMM ************** DO NOT EDIT THIS FILE **************
20 XCOMM CDE_INSTALLATION_TOP/bin/Xsession is a factory-default file and will
21 XCOMM be unconditionally overwritten upon subsequent installation.
22 XCOMM Modification is discouraged.
24 XCOMM $TOG: Xsession.src /main/19 1999/03/30 09:38:50 mgreess $
26 XCOMM Usage: $0 [-session session_name]
28 XCOMM ##########################################################################
36 if [ -z "$OPENWINHOME" ]
38 export OPENWINHOME="/usr/openwin"
45 * Platform specific definitions
47 * cpp_XINITUSER - user's xinit startup file
48 * cpp_MAIL - system mail file
49 * cpp_HELLO - dthello command line
50 * cpp_XDMSYS - xdm system session file
55 # define cpp_XINITUSER "$HOME/.xinitrc"
56 # define cpp_MAIL "/var/spool/mail/$USER"
57 #elif defined (__hpux)
58 # define cpp_XDMSYS "/usr/lib/X11/xdm/sys.xsession"
60 # define cpp_XINITUSER "$HOME/.xinitrc"
61 # define cpp_MAIL "/var/mail/$USER"
63 # define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
66 #if defined (__hpux) && defined (BLS)
68 # define cpp_HELLO "$DT_BINPATH/dthello -file /etc/copyright -file $HOME/.dtlogininfo &"
72 # define cpp_MAIL "/var/spool/mail/$USER"
73 # define cpp_XDIR "/usr/bin"
74 # define cpp_XINITUSER "$HOME/.xinitrc"
75 # define cpp_XDMSYS "/etc/X11/Xsession"
77 # define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
81 # define cpp_MAIL "/var/mail/$USER"
82 # define cpp_XINITUSER "$HOME/.xinitrc"
83 # define cpp_XDMSYS "/usr/local/lib/X11/xdm/Xsession"
85 # define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
89 # define cpp_MAIL "/var/mail/$USER"
90 # define cpp_XINITUSER "$HOME/.xinitrc"
91 # define cpp_XDMSYS "/etc/X11/xdm/Xsession"
93 # define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
97 # define cpp_MAIL "/var/mail/$USER"
98 # define cpp_XINITUSER "$HOME/.xinitrc"
99 # define cpp_XDMSYS "/etc/X11/xdm/Xsession"
101 # define cpp_HELLO "$DT_BINPATH/dthello -file $DT_INSTALL/copyright &"
107 * Fallback definitions
111 #if !defined (cpp_XINITUSER)
112 # define cpp_XINITUSER "$HOME/.x11start"
115 #if !defined (cpp_MAIL)
116 # define cpp_MAIL "/var/mail/$USER"
119 #if !defined (cpp_HELLO)
120 # define cpp_HELLO "$DT_BINPATH/dthello &"
123 #if !defined (cpp_XDMSYS)
124 # define cpp_XDMSYS "/usr/lib/X11/xdm/Xsession"
127 XCOMM ##########################################################################
130 XCOMM This script starts the user's session. It searches for one of three
131 XCOMM types of startup mechanisms, in the following order:
133 XCOMM DT existence of CDE DT Session Manager on the system
134 XCOMM XDM "$HOME/.xsession" (executable)
135 XCOMM xinit cpp_XINITUSER (executable)
137 XCOMM If none of these startup mechanisms exist, a default window manager
138 XCOMM and terminal emulator client are started.
140 XCOMM ##########################################################################
143 XCOMM Variables must be explicitly exported
147 XCOMM ##########################################################################
149 XCOMM Initialize session startup logging
151 XCOMM ##########################################################################
153 exec >/dev/null 2>/dev/null
156 LOGFILENAME=$LOGDIR/startlog
157 MSGLOGFILENAME=$LOGDIR/errorlog
159 if [ ! -d $LOGDIR ]; then
161 if [ -d $LOGDIR ]; then
166 [ -f $LOGFILENAME.older ] && rm -f $LOGFILENAME.older
167 [ -f $LOGFILENAME.old ] && mv -f $LOGFILENAME.old $LOGFILENAME.older
168 [ -f $LOGFILENAME ] && mv -f $LOGFILENAME $LOGFILENAME.old
170 [ ! -f $MSGLOGFILENAME ] && touch $MSGLOGFILENAME
172 if [ -w $LOGFILENAME ]; then
173 exec >>$LOGFILENAME 2>&1
179 echo "--- $1" >>$LOGFILENAME 2>&1
185 XCOMM ##########################################################################
187 XCOMM Global environment section
189 XCOMM DT pre-sets the following environment variables for each user.
193 XCOMM DISPLAY set to the value of the first field in the Xservers file.
194 XCOMM HOME set to the user's home directory (from /etc/passwd)
195 XCOMM LANG set to the display's current NLS language (if any)
196 XCOMM LC_ALL set to the value of $LANG
197 XCOMM LOGNAME set to the user name
198 XCOMM PATH set to the value of the Dtlogin "userPath" resource
199 XCOMM USER set to the user name
200 XCOMM SHELL set to the user's default shell (from /etc/passwd)
201 XCOMM TZ set to the value of the Dtlogin "timeZone" resource
206 XCOMM TERM set to xterm
207 XCOMM EDITOR set to the default editor
208 XCOMM KBD_LANG set to the value of $LANG for certain languages
209 XCOMM MAIL set to cpp_MAIL
212 XCOMM Three methods are available to modify or add to this list depending
213 XCOMM on the desired scope of the resulting environment variable.
215 XCOMM 1. X server and/or all users on a display (Xconfig file)
216 XCOMM 2. all users on a display (Xsession file)
217 XCOMM 3. individual users (.dtprofile file)
219 XCOMM See DT on-line help, the DT Users Guide, or the Dtlogin(1X) man
220 XCOMM page for details on setting environment variables.
223 XCOMM ##########################################################################
225 [ -z "$EDITOR" ] && EDITOR=CDE_INSTALLATION_TOP/bin/dtpad
226 [ -z "$MAIL" ] && MAIL=cpp_MAIL
227 [ -z "$LANG" ] && LANG="C"
229 SESSION_SVR=`hostname`
231 export PATH EDITOR MAIL TERM SESSION_SVR LANG
233 #if defined (_AIX) && defined (AIXV4)
235 XCOMM Clear the LFT message locale override if set
237 if [ "$LC_MESSAGES" = "C@lft" ]
245 HASH Set the keyboard language if necessary...
250 bulgarian | czech | hebrew | hungarian | \
251 japanese | korean | polish | rumanian | \
252 russian | serbocroatian)
256 chinese-t) KBD_LANG=t_chinese
258 chinese-s) KBD_LANG=s_chinese
267 HASH Locate configuration file directories
269 XDIR=XPROJECTROOT/bin
270 DT_BINPATH=CDE_INSTALLATION_TOP/bin
271 DT_INSTALL=CDE_INSTALLATION_TOP
272 DT_INSTALL_CONFIG=CDE_INSTALLATION_TOP/config
273 DT_CONFIG=CDE_CONFIGURATION_TOP/config
274 DT_CONFIG_PATH="$DT_INSTALL_CONFIG $DT_CONFIG"
276 XCOMM ##########################################################################
278 XCOMM Default desktop component configuration variable settings
280 XCOMM This section sets the default value for variables controlling
281 XCOMM some desktop components.
283 XCOMM ##########################################################################
286 HASH Input method server startup
288 if [ -z "$DTSTARTIMS" ]; then
292 if [ "$DTSTARTIMS" = "False" ]; then
297 HASH Default desktop screen saver action list
299 export DTSCREENSAVERLIST="StartDtscreenSwarm StartDtscreenQix \
300 StartDtscreenFlame StartDtscreenHop StartDtscreenImage StartDtscreenLife \
301 StartDtscreenRotor StartDtscreenPyro StartDtscreenWorm StartDtscreenBlank"
304 HASH Session startup clients and args
306 if [ "$SESSIONTYPE" = "altDt" ]; then
307 dtstart_session[0]="$SDT_ALT_SESSION"
308 dtstart_hello[0]="$SDT_ALT_HELLO"
311 if [ $# -ge 2 ]; then
312 if [ "$1" = "-session" ]; then
313 DTSESSION_ARGS="$1 $2"
316 dtstart_session[0]="$DT_BINPATH/dtsession $DTSESSION_ARGS"
317 dtstart_hello[0]=cpp_HELLO
319 dtstart_session[1]="$HOME/.xsession"
320 dtstart_session[2]=cpp_XINITUSER
321 dtstart_session[3]="$XDIR/xterm -geometry 80x24+10+10"
322 dtstart_hello[1]="$XDIR/xsetroot -default &"
323 dtstart_searchpath="$DT_BINPATH/dtsearchpath -ksh"
324 dtstart_ttsession="$DT_BINPATH/ttsession -s"
325 dtstart_dtdbcache="$DT_BINPATH/dtdbcache -init"
327 HASH dtdbcache file's directory should match
328 HASH _DTDTSMMTEMPDIR in DtSvc/DtUtil1/DtsMM.h
330 dtdbcacherm="rm -f /tmp/dtdbcache_$DISPLAY"
331 dtstart_appgather="$DT_BINPATH/dtappgather &"
333 dtstart_dsdm="$DT_BINPATH/dsdm &"
336 xdmstart_session[0]="$HOME/.xsession"
337 xdmstart_session[1]=cpp_XDMSYS
338 xdmstart_session[2]="xterm -geometry 80x24+10+10 -ls"
339 xdmstart_hello="$XDIR/xsetroot -default &"
342 SESSIONLOGDIR=$LOGDIR/sessionlogs
343 SESSIONLOGFILENAME="$SESSIONLOGDIR/$SESSION_SVR"_DISPLAY=$DISPLAY
345 if [ ! -d $SESSIONLOGDIR ]; then
347 if [ -d $SESSIONLOGDIR ]; then
348 chmod 755 $SESSIONLOGDIR
352 touch $SESSIONLOGFILENAME
354 if [ -w $SESSIONLOGFILENAME ]; then
355 dtstart_sessionlogfile="$SESSIONLOGFILENAME"
357 dtstart_sessionlogfile="/dev/null"
360 rm -f $SESSIONLOGFILENAME
363 if [ "$DTXSERVERLOCATION" != "remote" ]
366 HASH Start fallback console
368 if [ -x $XDIR/fbconsole ]
376 #include "_common.ksh.src"
379 XCOMM ##########################################################################
381 XCOMM Source user's desktop profile
383 XCOMM This section determines if the user has a desktop profile in their
384 XCOMM home directory. If not, the desktop default profile is copied to
385 XCOMM the home directory. The desktop profile is then sourced. The purpose
386 XCOMM is to incorporate any per-user/per-session environment customizations
387 XCOMM and thereby propagate them to applications and desktop components.
389 XCOMM ##########################################################################
392 DTSYSPROFILE=sys.dtprofile
395 if [ ! -f $HOME/$DTPROFILE ]; then
396 for i in $DT_CONFIG_PATH
398 if [ -f $i/$DTSYSPROFILE ]; then
401 /SYSPROFILE COMMENT START/ {printit=0; next}
402 /SYSPROFILE COMMENT END/ {printit=1; next}
403 printit==1 {print}' <$i/$DTSYSPROFILE >$HOME/$DTPROFILE
404 /bin/chmod 755 $HOME/$DTPROFILE
411 HASH source the .dtprofile.
413 if [ -f $HOME/$DTPROFILE ]; then
414 dtprofile_errors=`KORNSHELL -n $HOME/$DTPROFILE 2>&1`
415 if [ "0" = "$?" ]; then
416 Log "sourcing $HOME/$DTPROFILE..."
419 Log "not sourcing $HOME/$DTPROFILE due to errors..."
420 Log "$dtprofile_errors"
425 XCOMM ##########################################################################
427 XCOMM External Xsession processing section
429 XCOMM This section searches the Xsession.d subdirectory and sources
430 XCOMM the files contained therein. The purpose is to set up any
431 XCOMM per-user/per-session environment customizations and thereby propagate
432 XCOMM them to applications and desktop components.
434 XCOMM ##########################################################################
436 DT_XSESSION_DIR=Xsession.d
438 for i in $DT_CONFIG_PATH
440 if [[ -d $i/$DT_XSESSION_DIR ]]; then
442 HASH Run custom Xsession scripts for this session.
444 for SCRIPT in $(ls $i/$DT_XSESSION_DIR); do
445 if [ -x $i/$DT_XSESSION_DIR/$SCRIPT -a \
446 \( ! -d $i/$DT_XSESSION_DIR/$SCRIPT \) ]; then
447 Log "sourcing $i/$DT_XSESSION_DIR/$SCRIPT..."
448 . $i/$DT_XSESSION_DIR/$SCRIPT
455 XCOMM ##########################################################################
457 XCOMM Startup section.
459 XCOMM Note: The ksh syntax ${parameter%% *} is used when appropriate to
460 XCOMM remove any command line options that may have been included
461 XCOMM in the definition of a DT executable below.
463 XCOMM ##########################################################################
466 XCOMM Return first command in array named by $1 that is executable
472 eval "cmd=\${$1[$i]}"
473 [ -z "$cmd" ] && break
474 [ -x "${cmd%% *}" ] && echo "$cmd" && break
475 Log "could not start $cmd"
481 XCOMM Start first command in array named by $1 that is executable. If
482 XCOMM $2 is 'eval', command result will be 'eval'ed.
487 if [ ! -z "$first" ]; then
488 Log "starting $first"
489 if [ "$2" = "eval" ]; then
490 eval `eval "PATH=$DT_BINPATH:$PATH $first"`
492 eval "PATH=$DT_BINPATH:$PATH $first"
498 HASH Prepare for session startup
501 if [ "$DTSOURCEPROFILE" = "true" ]
504 sh | ksh | ksh93 | dtksh) shellprofile="$HOME/.profile";;
505 bash) shellprofile="$HOME/.bash_profile";;
506 csh | tcsh) shellprofile="$HOME/.login";;
507 *) Log "non-standard shell $SHELL"
511 if [ "$shellprofile" -a ! -f "$shellprofile" ]
513 Log "could not read $shellprofile"
517 if [ "$SESSIONTYPE" = "xdm" ]; then
518 startup=$(GetFirst xdmstart_session) # get xdm session client
519 StartFirst xdmstart_hello # start xdm hello client
521 startup=$(GetFirst dtstart_session) # get desktop session client
522 StartFirst dtstart_hello # start desktop hello client
523 StartFirst dtstart_searchpath eval # setup desktop search paths
525 tooltalk=$(GetFirst dtstart_ttsession) # get tooltalk client
526 dtdbcache=$(GetFirst dtstart_dtdbcache) # get dtdbcache client
529 if [ -z "$SDT_NO_DSDM" ]; then
530 StartFirst dtstart_dsdm # start drag and drop proxy
533 StartFirst dtstart_appgather # setup session applications
537 HASH Start the session.
540 if [ $shellprofile ]; then
541 Log "execing $startup using $shellprofile..."
545 sh | bash | ksh | ksh93 | dtksh)
546 dotprofile_errors=`$SHELL -n $shellprofile 2>&1`
547 if [ "0" = "$?" ]; then
548 source_profile=". $shellprofile"
549 source_login="source $shellprofile"
551 Log "parse errors found in $shellprofile..."
552 Log "$dotprofile_errors"
553 source_profile="echo 'not execing $shellprofile due to errors'"
554 source_login="echo 'not execing $shellprofile due to errors'"
558 source_profile=". $shellprofile"
559 source_login="source $shellprofile";;
563 Log "execing $startup..."
565 source_profile="echo 'not execing $HOME/.profile (see $HOME/.dtprofile)'"
566 source_login="echo 'not execing $HOME/.login (see $HOME/.dtprofile)'"
569 if [ -z "$dtdbcache" ]; then
570 dtdbcache="echo could not start $dtstart_dtdbcache"
575 sh | bash) $SHELL -c "$source_profile; \
578 PATH=$DT_BINPATH:\$PATH $tooltalk; \
579 $startup > $dtstart_sessionlogfile 2>&1" ;;
581 ksh | ksh93 | dtksh) $SHELL -c "$source_profile; \
584 PATH=$DT_BINPATH:\$PATH $tooltalk;\
585 $startup >| $dtstart_sessionlogfile 2>&1" ;;
587 csh | tcsh) $SHELL -c "unsetenv _ PWD; \
591 (set path = ( $DT_BINPATH \$path ); $tooltalk ); \
592 $startup >&! $dtstart_sessionlogfile" ;;
596 StartFirst dtstart_ttsession
597 $startup >| $dtstart_sessionlogfile 2>&1 ;;
600 $dtdbcacherm # remove the actions/datatypes cachefile
602 XCOMM #################### eof #################################