gdm, xdm environment

Matthew Hawkins matthew at topic.com.au
Wed Jan 9 16:09:39 EST 2002


On the subject of .xsession files, I thought I'd share mine.
Consider it public domain.

Features:
 * detection and special handling of dual-head setup
 * interesting progress logging (idea from Adam Spiers http://www.adamspiers.org/)
   - useful when debugging why your X session didn't start.
 * straightforward switching of default session manager, and handling command-line switches
 * emergency session managers (ones you hope will always work, like xterm, xsm)
   - useful when hacking on window manager code ;)
 * graceful startup/shutdown of SSH key server, plus addition of keys on login
 * handling wm-specific issues when necessary

TODO:
 * more config variables, for font paths and xrdb files
 * "xsetroot -cursor" configuration

----------
MATTS_SM=wmaker
#MATTS_SM=blackbox
#MATTS_SM=fluxbox
#MATTS_SM=vtwm
#MATTS_SM=xsession
#MATTS_SM=xsm
#MATTS_SM=xterm
MATTS_SM_OPTS=""
# start gkrellm in withdrawn mode so blackbox/fluxbox whacks
# it into the slit
GKRELLM_OPTS="-w"

[ -d ~/bin ] && PATH=~/bin:"$PATH"

echo -n "X session started: "
date
#: ${HOST:=${HOSTNAME:={`hostname`}}}
if [ -z "$HOST" ]; then
	HOST=`hostname`
fi
if [ -z "$HOSTNAME" ]; then
	HOSTNAME=$HOST
fi
export HOST HOSTNAME
echo "    on host $HOST ($HOSTNAME)"

xrdb -merge -global $HOME/.Xresources
xset fp+ $HOME/share/fonts
xset fp rehash
xset m 4 5
xset r rate 250 50
xset r rate 250 70

# If we are ssh-enabled, start the key server
id1=$HOME/.ssh/identity
id2=$HOME/.ssh/id_dsa
id3=$HOME/.ssh/id_rsa
if [ -e /usr/bin/ssh-agent ] && [ -f $id1 -o -f $id2 -o -f $id3 ];
then
	echo "launching SSH key server"
	eval `ssh-agent -s`
	ssh-add $id1 $id2 $id3 < /dev/null
fi

xscreensaver -no-splash&

# Find how many screens we have
numscreens=`xdpyinfo | awk '/^number.*screen/ { print $4 }'`
echo "found $numscreens screen(s)"

# my eyes might be going, but I'll be buggered if my wrists are joining them
xwrits mono maxhands=100 --typetime=40 --breaktime=2 +cheat=0 +mouse=15 +beep +breakclock +clock +noiconify +top +multiply=1:00 +quota=1 minbreaktime=3 after=1 +finger=american +multiply=0:10 --breaktime=3 +lock password=quit +multiply=0:0.30 &

case "$MATTS_SM" in
	blackbox)
		bbkeys -w -m& 
		#bbpager -w&
		if [ $numscreens -gt 1 ]; then
			MATTS_SM_OPTS="-rc $HOME/.blackboxrc-dh"
		else
			MATTS_SM_OPTS="-rc $HOME/.blackboxrc-sh"
		fi
		;;
	fluxbox)
		if [ $numscreens -gt 1 ]; then
			MATTS_SM_OPTS="-rc $HOME/.fluxbox/init-dualhead"
		else
			MATTS_SM_OPTS="-rc $HOME/.fluxbox/init-singlehead"
		fi
		;;
	wmaker)
                # disable withdrawn mode since that's special-cased for
                # dockapps.  Turn off transparency and just whack it in
                # the top left corner where I have the slit in bb/fb
		GKRELLM_OPTS="-nt -g +0+0"
		;;
esac

# Fire up gkrellm appropriately
if [ $numscreens -gt 1 ]; then
echo "starting gkrellm on second screen/head"
DISPLAY=:0.1
gkrellm $GKRELLM_OPTS &
DISPLAY=:0
else
echo "starting gkrellm on only screen/head"
gkrellm $GKRELLM_OPTS &
fi

# Finally, launch our session manager
$MATTS_SM $MATTS_SM_OPTS
if [ "$SSH_AGENT_PID" ]; then
	echo "destroying SSH key server"
	ssh-add -D < /dev/null
	eval `ssh-agent -s -k`
fi
----------

-- 
Matt




More information about the linux mailing list