Xsession

A display manager refers to a user's login and startup of a window manager and desktop as a session. When the user quits the desktop and logs out, the session ends. When another user logs in, a new session starts. The X Window System never shuts down; only desktop or window manager programs shut down. Session menus on the display manager login window list different kinds of sessions you can start—in other words, different kinds of window managers or desktops. For each session, the Xsession script is the startup script used to configure a user's X Window System display and to execute the selected desktop or window manager. Although this script is unnecessary for gdm, it is still used in the gdm Red Hat implementation.

Xsession is the display manager session startup script used by the Red Hat implementation of gdm (other display managers such as kdm and xdm also use Xsession). It contains many of the X commands also used with the xinitrc startup script. Xsession usually executes the same xmodmap and xrdb commands using the .Xmodmap and .Xrsources files in the /etc/X11/xinit directory. Shown here is the Xsession script used by gdm on Red Hat systems, which is located in the /etc/X11/xdm directory. Notice that any errors are saved in the user's .xsession-errors file in their home directory. Xsession will also read any shell scripts located in the /etc/X11/xinit/xinitrc.d directory. Currently this holds an input script to detect the kind of language a keyboard uses.

/etc/X11/xdm/Xsession

# redirect errors to a file in user's home directory if we can for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER"

"/tmp/xses-$USER"

do if cp /dev/null "$errfile" 2> /dev/null ; then chmod 600 "$errfile" exec > "$errfile" 2>&1 break fi done xsetroot -solid '#356390'

userresources=$HOME/.Xresources usermodmap=$HOME/.Xmodmap userxkbmap=$HOME/.Xkbmap sysresources=/etc/X11/Xresources sysmodmap=/etc/X11/Xmodmap sysxkbmap=/etc/X11/Xkbmap

# merge in defaults if [ -f "$sysresources" ]; then xrdb -merge "$sysresources"

fi if [ -f "$userresources" ]; then xrdb -merge "$userresources"

# merge in keymaps if [ -f "$sysxkbmap" ]; then setxkbmap "cat "$sysxkbmap"N XKB_IN_USE=yes fi

# run all system xinitrc shell scripts. for i in /etc/X11/xinit/xinitrc.d/* ; do if [ -x "$i" ]; then . "$i"

fi done

# now, we see if xdm/gdm/kdm has asked for a specific environment case $# in

case $1 in failsafe)

exec xterm -geometry 80x24-0-0 ;;

gnome)

exec gnome-session ;;

kde|kde1|kde2)

exec /usr/share/apps/switchdesk/Xclients.kde twm)

# fall back to twm exec /usr/share/apps/switchdesk/Xclients.twm

# otherwise, take default action if [ -x "$HOME/.xsession" ]; then exec "$HOME/.xsession" elif [ -x "$HOME/.Xclients" ]; then exec "$HOME/.Xclients" elif [ -x /etc/X11/xinit/Xclients ]; then exec /etc/X11/xinit/Xclients else

# should never get here; failsafe fallback exec xsm fi

Xsession is usually invoked with an argument indicating the kind of environment to run, such as Gnome, KDE, or a window manager like Window Maker. The option for Gnome would be gnome and for KDE it would be kde.

Xsession gnome

These environments are listed in the Xsession script within the case statement. Here you will find entries for Gnome, KDE, and the bare-boned twm window manager. On Red Hat, gnome is invoked directly with the gnome-session command, whereas KDE and other window managers are invoked through scripts set up for the Red Hat switchdesk tool. These scripts contain a simple command to invoke a window manager. The scripts are held in the /usr/share/apps/switchdesk directory. Each file has the prefix "Xclients" and the suffix with the name of the window manger or desktop. For example, the KDE script is Xclients.kde, and the Window Maker script is Xclients.windowmaker.

If Xsession is not invoked with a specific environment, the user's home directory is checked for a .xession or .Xclients script. If those scripts are missing, the system Xclients script is used, /etc/X11/xinit/Xclients.

If users want to set up their own startup files, they can copy the Xsession file to the their home directory and name it .xsession and then edit it. The following example shows a simplified Xsession script that executes the user's .xsession script if it exists. The user's

.xsession script is expected to start a window manager or desktop.

# Xsession

# This is the program that is run as the client

# for the display manager.

startup=$HOME/.xsession resources=$HOME/.Xresources if [ -f "$startup" ]; then exec "$startup" else if [ -f "$resources" ]; then xrdb -load "$resources"

fi fvwn2 &

exec xterm -geometry 80x24+10+10 -ls fi

Continue reading here: The X Display Manager xdm

Was this article helpful?

0 0