So, you've decided to take control of your X session. Let's
get started.
You should first go read the simple way of doing this. Click here. Go
ahead, I'll wait.
OK, now you know how to edit /opt/kde/share/config/kdmrc . So let's start hacking...
#!/bin/sh
# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
# $Id: Xsession,v 1.6 1998/09/29 16:49:02 bieker Exp $
# modified for COL 2.2 by Matthias Hoelzer-Kluepfel
# further hacked by Douglas Hunley
wm=$1
if [ -r "$HOME/.profile" ]; then
. "$HOME/.profile"
else
[ -r /etc/config.d/shells/bashrc ] && . /etc/config.d/shells/bashrc
[ -r /etc/config.d/shells/profile ] && . /etc/config.d/shells/profile
fi
# redirect errors to a file in user's home directory if we can
for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER"
do
if ( cp /dev/null "$errfile" 2> /dev/null )
then
chmod 600 "$errfile"
exec > "$errfile" 2>&1
break
fi
done
if [ -z "$KDEDIR" ] ; then
KDEDIR=/opt/kde
export KDEDIR
fi
if [ -z "$GNOMEDIR" ] ; then
GNOMEDIR=/opt/gnome
export GNOMEDIR
fi
PATH=$KDEDIR/bin:$GNOMEDIR/bin:$PATH
export PATH
if [ -n "$wm" ]; then
case $wm in
kde)
exec /etc/X11/xinit/kde
;;
kde2)
KDEDIR=/opt/kde2
export KDEDIR
exec /etc/X11/xinit/kde2
;;
e)
exec /etc/X11/xinit/e
;;
gnome)
exec /etc/X11/xinit/gnome
;;
failsafe)
exec xterm -geometry 80x24-0-0
;;
*)
which "$wm" && exec /etc/X11/xinit/xinitrc `which $wm`
# windowmanager not found, tell user
message="Sorry, $wm not found."
if [ -x $KDEDIR/bin/kdialog ]; then
exec $KDEDIR/bin/kdialog --msgbox "$message"
else
exec xmessage -center "$message"
fi
;;
esac
else
message="No window manager specified"
if [ -x $KDEDIR/bin/kdialog ]; then
exec $KDEDIR/bin/kdialog --msgbox "$message"
else
exec xmessage -center "$message"
fi
fi
#!/bin/sh
# Hacked together from common sources and modified by Douglas Hunley
# do the default thing that is common to all environments
# where is the xinit dir
if [ x"$XWINHOME" != x ]; then
XINIT_DIR=$XWINHOME/lib/X11/xinit
else
XINIT_DIR=/etc/X11/xinit
fi
# support for Sun's OpenWindows
export OPENWINHOME=/usr/openwin
export HELPPATH=$OPENWINHOME/help
# all the relevant X resources
sysmodmap=$XINIT_DIR/.Xmodmap
usermodmap=$HOME/.Xmodmap
sysresources=$XINIT_DIR/.Xresources
userresources=$HOME/.Xresources
sysdefaults=$XINIT_DIR/.Xdefaults
userdefaults=$HOME/.Xdefaults
# what's the correct way to use xrdb
if [ -x /lib/cpp ]; then
XRDB=xrdb
else
XRDB="xrdb -nocpp"
fi
# build the X resources settings
for res in $sysresources $userresources $sysdefaults $userdefaults ; do
if [ -f $res ]; then
$XRDB -merge $res
fi
done
# alter the keymap as needed
for map in $sysmodmap $usermodmap ; do
if [ -f $map ] ; then
xmodmap $map
fi
done
# check for needed space
space_tmp=`df /tmp | xargs | cut -d" " -f11`
space_home=`df $HOME | xargs | cut -d" " -f11`
if [ $space_tmp -lt 50 ]; then
echo "Not enough free disk space on /tmp"
exit 1
fi
if [ $space_home -lt 25 ]; then
echo "Not enough free disk space on $HOME"
exit 1
fi
# check for needed write perms
testfile=X_$$.testfile
if ! echo TEST_TEXT >/tmp/$testfile 2>/dev/null ; then
echo "Have no write permissions for /tmp"
exit 1
fi
rm -f /tmp/$testfile
if ! echo TEST_TEXT >$HOME/$testfile 2>/dev/null ; then
echo "Have no write permissions for $HOME"
exit 1
fi
rm -f $HOME/$testfile
# now we do the environment specific things
# how were we called (i.e. what environment are we running)
case `basename $0` in
kde|kde2)
# KDE specific things
# Kill esd if running
killall esd >/dev/null 2>&1
# start the background module early to give visual feedback
$KDEDIR/bin/kbgndwm &
# create the kde-config-dir (essential for kpanel)
#if [ ! -d $HOME/.kde/config ]; then
# install -d -m 755 $HOME/.kde/config
#fi
# create the 2nd config dir for KDE
for dir in Desktop/Autostart Desktop/Trash .kde/share/apps/kfm; do
if [ ! -d $HOME/$dir ]; then
install -m 700 -d $HOME/$dir
fi
done
f=$HOME/.kde/share/apps/kfm/magic
[ -f $f ] || dd if=/dev/random bs=1 count=16 | md5sum > $f
#if [ ! -d $HOME/Desktop/Templates ]; then
# install -m 700 -d $HOME/Desktop/Templates
# cp -a $KDEDIR/share/apps/kfm/Desktop/Templates/* $HOME/Desktop/Templates
#fi
# copy the default keyboard configuration file
if [ ! -f $HOME/.kde/share/config/kikbdrc ]; then
install -d -m 700 $HOME/.kde/share/config
install -m 644 $KDEDIR/share/config/kikbdrc $HOME/.kde/share/config/kikbdrc
fi
# create the default kderc file
if [ ! -f $HOME/.kderc ]; then
install -m 644 $KDEDIR/share/config/kderc $HOME/.kderc
source /etc/system.cnf
echo "[Locale]" >> $HOME/.kderc
echo "Language=$CONF_LST_LANG:C:C" >> $HOME/.kderc
fi
if [ ! -f $HOME/.kde/share/config/kvtrc ]; then
install -m 644 $KDEDIR/share/config/kvtrc $HOME/.kde/share/config/kvtrc
fi
exec $KDEDIR/bin/startkde
;;
e)
# Enlightenment specific things (under KDE)
$KDEDIR/bin/kbgndwm &
for dir in Desktop/Autostart Desktop/Trash .kde/share/apps/kfm; do
if [ ! -d $HOME/$dir ]; then
install -m 700 -d $HOME/$dir
fi
done
f=$HOME/.kde/share/apps/kfm/magic
[ -f $f ] || dd if=/dev/random bs=1 count=16 | md5sum > $f
if [ ! -f $HOME/.kde/share/config/kikbdrc ]; then
install -d -m 700 $HOME/.kde/share/config
install -m 644 $KDEDIR/share/config/kikbdrc $HOME/.kde/share/config/kikbdrc
fi
if [ ! -f $HOME/.kderc ]; then
install -m 644 $KDEDIR/share/config/kderc $HOME/.kderc
source /etc/system.cnf
echo "[Locale]" >> $HOME/.kderc
echo "Language=$CONF_LST_LANG:C:C" >> $HOME/.kderc
fi
if [ ! -f $HOME/.kde/share/config/kvtrc ]; then
install -m 644 $KDEDIR/share/config/kvtrc $HOME/.kde/share/config/kvtrc
fi
kcontrol -init
exec kfm &
exec krootwm &
exec kpanel &
(sleep 1; krunonce kdewizard &)
$GNOMEDIR/bin/esd &
exec $GNOMEDIR/enlightenment/bin/enlightenment
;;
gnome)
# Gnome specific things
exec $GNOMEDIR/bin/gnome-session
;;
xinitrc)
# unknown window manager things
exec ${1-/usr/X11R6/bin/twm}
;;
esac
As you can see, we have KDE, Gnome, and Enlightenment on our
machine. Edit the
file to match your site. Each different environment/window
manager gets a stanza
of its own in our case statement. We use these stanzas to
start up things
specific to that environment (like the KDE sound daemon, or
the Gnome sound
daemon). The really neat thing about this is that if we
install another window
manager that doesn't need anything specific (like afterstep),
we DO NOT
need to add another stanza. The last stanza, called 'xinitrc'
will launch the
window manager automatically (IF IT IS IN YOUR PATH).
Isn't that slick?
Now, given our above example, we would cd to /etc/X11/xinit
and we would issue
the following commands:
ln -s xinitrc e ln -s xinitrc gnome ln -s xinitrc kde ln -s xinitrc kde2
That's the magic at work here. Our new xinitrc file examines
how it was called,
and uses that to determine which stanza in the case statement
gets executed.
That's why running afterstep without creating it's own stanza
will work. You
will have to create a symbolic link for afterstep:
ln -s xinitrc afterstepbut you will not need to add a stanza. Kewl ain't it?
Another neat effect of this change shows up under run-level
3. If you ever end
up at the command-line (console mode), you can now tell startx
which window
manager to start. Simply pass the full-path name to the window
manager as the
last argument to startx. For example:
startx -- -bpp 16 /opt/gnome/bin/gnome-sessionwould start Gnome for you. You can start any of the environments this way!
|
|
|