1 #!/bin/bash 2 # 3 # Script for starting a desktop session 4 # 5 # CDDL HEADER START 6 # 7 # The contents of this file are subject to the terms of the 8 # Common Development and Distribution License, Version 1.0 only 9 # (the "License"). You may not use this file except in compliance 10 # with the License. 11 # 12 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 13 # or http://www.opensolaris.org/os/licensing. 14 # See the License for the specific language governing permissions 15 # and limitations under the License. 16 # 17 # When distributing Covered Code, include this CDDL HEADER in each 18 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 19 # If applicable, add the following below this CDDL HEADER, with the 20 # fields enclosed by brackets "[]" replaced with your own identifying 21 # information: Portions Copyright [yyyy] [name of copyright owner] 22 # 23 # CDDL HEADER END 24 # 25 # 26 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27 # Use is subject to license terms. 28 # 29 30 MYNAME=$(basename $0) 31 32 usage() { 33 echo "Usage: $0 session_name" 34 echo " This script loads scripts in /etc/X11/xinit/xinitrc.d" 35 echo " and runs a session manager." 36 echo " session_name is gnome, twm or xdm" 37 } 38 39 if [ $# -ne 1 ]; then 40 usage 41 exit 1 42 fi 43 44 case "$1" in 45 -h|--help|-\?) 46 usage 47 exit 0 48 ;; 49 esac 50 51 SESSION_NAME="$1" 52 shift 53 54 case "$SESSION_NAME" in 55 gdm|GDM|gnome|GNOME|jds|JDS) 56 SESSION_MANAGER=/usr/bin/gnome-session ;; 57 tjds|TJDS|TrustedJDS|tgnome|TGNOME) 58 SESSION_MANAGER='/usr/bin/gnome-session --trusted-session';; 59 twm|TWM) SESSION_MANAGER=/usr/X11/bin/twm ;; 60 xdm|XDM) SESSION_MANAGER=/usr/openwin/lib/X11/xdm/Xsession ;; 61 console) exit 0 ;; 62 *) 63 if [ "x$SESSION_NAME" != x ] ; then 64 SESSION_MANAGER=$SESSION_NAME 65 fi 66 if [ ! -x $SESSION_NAME ] ; then 67 echo "Could not find session startup for $SESSION_NAME" 68 SESSION_MANAGER=/usr/X11/bin/twm 69 fi 70 71 esac 72 73 # GDM slave sets DESKTOP_SESSION environment from .desktop file. 74 export DESKTOP_SESSION=$SESSION_NAME 75 76 # run all system xinitrc shell scripts. 77 if [ -d /etc/X11/xinit/xinitrc.d ]; then 78 for i in /etc/X11/xinit/xinitrc.d/* ; do 79 if [ -x "$i" ]; then 80 . "$i" 81 fi 82 done 83 fi 84 85 exec $SESSION_MANAGER $@ 86 87