#!/bin/csh -f # $Id: XStartup,v 1.11 2000-05-10 17:08:25+02 jv Exp jv $ cd ${HOME} set verbose set verify # X11Startup control file # # This is a C-Shell file, since it processes .cshrc for basic setup. # Slave files are processed by the 'normal' Bourne shell, as specified # in variable SH (not SHELL!). # # The window manager is started from this script, since it needs # environments and PATH setenv WM_START 1 switch ( $#argv ) case 1: switch ( "$argv[1]" ) case xdm: setenv WM_SESSION 1 setenv WM_TOOLS 1 breaksw case noxdm: unsetenv WM_SESSION setenv WM_TOOLS 1 breaksw case tools: unsetenv WM_SESSION setenv WM_TOOLS 1 unsetenv WM_START default: unsetenv WM_START endsw breaksw endsw if ( ! $?WM_SESSION ) setenv WM_SESSION 0 if ( ! $?WM_START ) setenv WM_START 0 if ( ! $?WM_TOOLS ) setenv WM_TOOLS 0 set Start_dir = "$HOME/XStart" set SH = /bin/sh # We used to set path and PATH here, but that is no longer needed. # We trust .cshrc to set it. if ( -r ~/.cshrc ) source ~/.cshrc # if ( -r ~/.login ) source ~/.login # No UNICODE yet. setenv LANG en_US.iso8859-1 # Hostnames and such. HOSTNAME is the fqdn, DNSHOSTNAME is the short # name, DNSDOMAINNAME its DNS domain. setenv HOSTNAME `/bin/hostname --fqdn` setenv DNSDOMAINNAME `/bin/hostname --domain` setenv DNSHOSTNAME `/bin/hostname --short` # Select DISPLAY. Should not be needed. if ( ! $?DISPLAY ) then setenv DISPLAY :0 echo "DISPLAY set to $DISPLAY" endif # Load X properties. Turn -DPLANES=8 into "setenv X_PLANES 8" etc. #eval `xrdb -symbols | sed -ne 's/^-D\([^=]*\)=\(.*\)$/setenv X_\1 \2;/p' -e 's/^-D\([^=]*\)$/setenv X_\1 1;/p'` eval `xrdb -symbols -screen | sed -ne 's/^-D\(HEIGHT\|WIDTH\)=\(.*\)$/setenv X_\1 \2;/p' -e 's/^-D\(COLOR\)$/setenv X_\1 1;/p'` if ( ! $?X_WIDTH ) then echo "ERROR: No properties from X, using defaults." setenv X_WIDTH 1024 setenv X_HEIGHT 864 setenv X_COLOR 0 endif # Display dependent actions. setenv XSTART ${Start_dir}/${HOSTNAME}/${DISPLAY} if ( ! -d ${XSTART} ) mkdir -p ${XSTART} # Root background color. load_xdefaults uses it. if ( $X_COLOR == 1 ) then setenv ROOT_BGCOLOR LightSkyBlue3 set ROOT_COLOR = "-solid $ROOT_BGCOLOR" else #set ROOT_COLOR = "-solid grey" set ROOT_COLOR = endif # Xdefaults and Xmodmap. rm -f ${XSTART}/load_xdefaults cp ${Start_dir}/load_xdefaults ${XSTART}/load_xdefaults sh ${XSTART}/load_xdefaults # Set num lock. We need it. setleds +num xset r rate 300 50 # System dependent settings. switch ( "$DNSHOSTNAME" ) case phoenix: case c1525: xset m 4 # Nice beep xset b 100 2700 50 breaksw case deirdre: # slow mouse xset m 1 1 # Nice beep xset b 80 2000 40 # No screen saver xset s off xset -dpms breaksw case plume: xset m 3 # Serial mouse xset m 4 # Same mouse via PS/2 port xset b 100 2400 50 # xset r rate 500 20 breaksw case eithne: aumix -v30 # Used for presentions -> no blanking xset s 0 endsw # Bind keys. if ( -s ${HOME}/.xbindkeysrc-${DNSHOSTNAME} ) then xbindkeys -f ${HOME}/.xbindkeysrc-${DNSHOSTNAME} endif if ( $WM_TOOLS == 1 ) then # Remove remniscent wm selector files so the scripts can create one. rm -f ${XSTART}/wm # Startup files are real shell-scripts, organized in a separate # directory. ${XStart_dir} indicates this directory. # # Startup files are named XY-Name, where # # X - digit indicating the startup phase # Y - digit indicating precedence in this phase # Name - descriptive name # # For each phase (0..9) all files with precedence not greater than the # currently selected start level will be executed. # The start level is defined in .XStartLevel or XStartLevel. # .XStartLevel is a temporary start level, and removed after use. # XStartLevel is a permanent one, to be used if .XStartLevel is not # present. # Determine start level. set DotStartLevel_file = "$HOME/.XStartLevel" set StartLevel_file = "$HOME/XStartLevel" set StartLevel = 9 # CSH does not have -s, use test if ( { test -s ${DotStartLevel_file} } ) then set StartLevel = `cat ${DotStartLevel_file}` rm -f ${DotStartLevel_file} else if ( -f ${StartLevel_file} ) then if ( -z ${StartLevel_file} ) then set StartLevel = 0 # empty file, testing... else set StartLevel = `cat ${StartLevel_file}` endif endif endif echo "XStartLevel = ${StartLevel}" cd $HOME # Normally, start level is a number between 0 and 9, but it may be # something else (with slightly different semantics). switch ( "${StartLevel}" ) case [0-9]: set Pat = "0-${StartLevel}" breaksw default: set Pat = ${StartLevel} breaksw endsw # Select the scripts based on the start level pattern. foreach i ( ${Start_dir}/[0-9][${Pat}]-* ) switch ( $i:t ) case *~: breaksw case *,v: breaksw default: echo "XStart:" $i:t ${SH} $i breaksw endsw end endif # WM_TOOLS if ( $WM_START == 1 ) then # Select window manager. if ( -f ${XSTART}/wm ) source ${XSTART}/wm if ( ! $?WM_NAME ) then #setenv WM_NAME twm #setenv WM_NAME gwm # Bull Generic Window Manager. Cute. #setenv WM_NAME mwm # OSF/Motif Window Manager. Ouch. #setenv WM_NAME dxwm # DECwindows Window Manager. Yuck. #setenv WM_NAME tvtwm # Tom's (Virtual) Window Manager. Nice. setenv WM_NAME ctwm # Claude's Window Manager. Live free or die. endif # Window manager specific settings. switch ( "$WM_NAME" ) case ctwm: # Just set the root background color. xsetroot $ROOT_COLOR breaksw case tvtwm: # A nice feature of tvtwm: if a background picture is installed, # this will show up when the screen saver becomes active. if ( -f ~/X.background ) then xset s noblank xv -root -center -quit X.background else if ( -f /usr/local/bin/xphoon ) then xset s noblank /usr/local/bin/xphoon else xsetroot $ROOT_COLOR endif endif breaksw default: # Set background image. if ( -f ~/X.background ) then xv -root -center -quit X.background else if ( -f /usr/local/bin/xphoon ) then /usr/local/bin/xphoon else xsetroot $ROOT_COLOR endif endif breaksw endsw # Window Manager startup options and config files. set WM_ARGS = "" if ( $?WM_ARGS ) set WM_ARGS = "$WM_ARGS" if ( $WM_NAME == "kde2" ) then set path = (/opt/kde2/bin $path) set WM_NAME = "startkde" endif if ( $WM_NAME == "ctwm" ) then cd ${Start_dir} echo 'define(`WM_ctwm'"',1)dnl" >${XSTART}/ctwmrc echo 'define(`WM_DIR'"',${XSTART})dnl" >>${XSTART}/ctwmrc echo 'define(`WM_LIB'"',${Start_dir})dnl" >>${XSTART}/ctwmrc echo 'define(`WM_WORKSPACES'"',6)dnl" >>${XSTART}/ctwmrc echo 'define(`WM_DISPLAY'"',${HOSTNAME}${DISPLAY})dnl" >>${XSTART}/ctwmrc if ( -f ${XSTART}/XSnow ) then echo 'define(`WM_NOSQUEEZE'"',1)dnl" >>${XSTART}/ctwmrc endif # ctwm can do RaiseDelay. echo 'define(`WM_RAISEDELAY'"',1)dnl" >>${XSTART}/ctwmrc # Nice 3D decorations. Requires XPM. echo 'define(`WM_CTWM3D'"',1)dnl" >>${XSTART}/ctwmrc if ( $?WM_PRES ) then if ( $WM_PRES != 0 ) then echo 'define(`WM_RANDOMPLACEMENT'"',1)dnl" >>${XSTART}/ctwmrc xset s off endif endif # Suppress startup screen. if ( ! $?CTWM_WELCOME_FILE ) then setenv CTWM_WELCOME_FILE 0 foreach file ( $HOME/icons/linux.xwd $HOME/icons/redhat.xwd ) if ( -f $file ) then setenv CTWM_WELCOME_FILE "xwd:$file" endif end endif # Check for Windows keys. Must be set using xmodmap. xmodmap | grep -q 'mod5.*(.*)' if ( ! $status ) then echo 'define(`WM_WINDOWS_KEY'"',m5)dnl" >>${XSTART}/ctwmrc endif # Add the X symbols. # xrdb -symbols | sed -ne 's/^-D\([^=]*\)=\(.*\)$/define(`X_\1'"'"',`\2'"'"')dnl/p' -e 's/^-D\(.*\)$/define(`X_\1'"'"',1)dnl/p' >>${XSTART}/ctwmrc echo "include(${Start_dir}/ctwmrc)dnl" >> ${XSTART}/ctwmrc # Append the config file. set WM_ARGS = "$WM_ARGS -k -f ${XSTART}/ctwmrc" endif cd $HOME # When the Window Manager should become the session controlling # process, indicated by WM_SESSION, we overlay it. Otherwise fire it # up in the background and exit this script. if ( $WM_SESSION == 1 ) then echo "Starting $WM_NAME window manager... ($WM_ARGS)" exec $WM_NAME $WM_ARGS # exec xterm -geometry +1 +1 -n xconsole -e 'cat < /dev/xcons' else echo "Backgrounding $WM_NAME window manager..." $WM_NAME $WM_ARGS & endif endif # WM_START # Local Variables: # mode: shell-script # End: