#!/bin/bash # # wm.xsession is called when a desktop environment is in use. It initializes # the keyboard, then sets up a nest of service daemons, then continues with # wm2.xsession. The eventual window manager and its arguments (if any) are # specified on the command line of this script. # This script contains bash-isms. Debian doctrine requires all startup scripts # to work with any shell. # Starting in SuSE 11.1 (xorg-x11-7.4), the X-server does not obey # the keyboard layout in /etc/X11/xorg.conf. A possible rationale is that # the keyboard layout should be a user preference; anyway, the user has # to set it now. # This script looks for a keyboard compilation script in the places listed # below; the first one found is executed. for f in $HOME/.xkeyboard.$HOSTNAME \ $HOME/.xkeyboard \ /m1/custom/xkeyboard \ /etc/X11/xdm/xkeyboard ; do if [ ! -x $f ] ; then continue ; fi $f break done # We need these service daemons, listed from outer to inner: # ConsoleKit session (seat), so the user gets permission for devices. # Dbus daemon for the session. # Gnome Keyring Daemon # SSH key agent. # GPG key agent. But both of these may be handled by Gnome Keyring Daemon. # Starting in SuSE 11.1, gnome-volume-manager is no longer used. # For each daemon, the script tests if its service is already provided by # the display manager (or more likely, the PAM script), and if the # prerequisites exist to start it. # The chain of nested commands goes in this variable: declare -a command # Set this to 1 to get debug output. opt_v=1 # ConsoleKit keeps track of which user is logged in at the console, mainly # so it can tell HAL to give permission on devices associated with the console. # So how can we tell if a prior step has already done the ck-launch-session # thing? pam_ck_connector sets XDG_SESSION_COOKIE into the environment. # ck-list-sessions can now list that session (but it appears to not be local). # For now, we'll unconditionally launch the session, except for session leaders # which are expected to register the session themselves. case "$1" in *kdm* | *gnome* ) # These register the session themselves : ;; * ) if cklaunch=$(type -p ck-launch-session) ; then if [ $opt_v -gt 0 ] ; then echo "Start $cklaunch" ; fi command+=($cklaunch /etc/X11/xdm/ck-launch-wrapper) fi ;; esac # Every session needs a Dbus daemon so daemons can chatter together. if test -z "$DBUS_SESSION_BUS_ADDRESS" && \ dbuslaunch=$(type -p dbus-launch) ; then if [ $opt_v -gt 0 ] ; then echo "Start $dbuslaunch" ; fi command+=($dbuslaunch --exit-with-session) YDBUS=1 fi # The Gnome Keyring Daemon should have been started by PAM, but if it wasn't, # fake it here. Including a per-session shepherd process to kill the daemon. # It does not have the command nesting feature that the other service daemons # do. if test -z "$GNOME_KEYRING_SOCKET" && \ gkd=$(type -p gnome-keyring-daemon) ; then if [ $opt_v -gt 0 ] ; then echo "Start $gkd" ; fi eval `$gkd --daemonize --components=ssh,keyring,pkcs11` if [ -n "$GNOME_KEYRING_PID" ] ; then SESS_PID=$$ ( while test -d /proc/$SESS_PID ; do sleep 300 ; done ; \ kill $GNOME_KEYRING_PID ) < /dev/null > /dev/null 2>&1 & YSSH=1 fi fi # The situation with the GPG agent is ambiguous. In SuSE 11.1 the distro- # provided sys.xsession tries to start seahorse-agent, which does not exist # and may have been renamed to seahorse-daemon; however, that daemon does # not seem to set GPG_AGENT_INFO, nor does it emit useful variables on stdout. # Therefore the (older?) gpg-agent is used instead. if test -z "$GPG_AGENT_INFO" -a -d "$HOME/.gnupg" && \ gpga=$(type -p gpg-agent) && \ pint=$(type -p pinentry) ; then if [ $opt_v -gt 0 ] ; then echo "Start $gpga" ; fi command+=($gpga --daemon --default-cache-ttl 68400 --pinentry-program $pint) # gpg-agent can emulate ssh-agent. If we don't already have # a ssh-agent, turn this feature on. if test -z "$SSH_AUTH_SOCK" -a -z "$YSSH" -a -d "$HOME/.ssh" ; then if [ $opt_v -gt 0 ] ; then echo " Add ssh support" ; fi command+=(--enable-ssh-support) YSSH=1 fi fi # If the user has ssh credentials he needs an agent to hold them. # Gnome Keyring Daemon also provides a ssh agent so this step is only effective # if g-k-d cannot be executed. if test -z "$SSH_AUTH_SOCK" -a -z "$YSSH" -a -d "$HOME/.ssh" && \ sshagent=$(type -p ssh-agent) ; then if [ $opt_v -gt 0 ] ; then echo "Start $sshagent" ; fi command+=($sshagent) YSSH=1 fi # After the nest of service daemons we will pick up in wm2.xsession. command+=(${0%/*}/wm2.xsession "$@") # Execute the nest of service daemons. exec "${command[@]}" echo "Failed to exec the service daemons. Command was:" 1>&2 echo "${command[*]}" 1>&2 exit 8