Linux Step By Steps
Window Managers

Jordan <jgrignon@home.com
Last updated 06/09/00 

Links: 
http://www.xfce.org 
http://www.gnome.org 

http://www.kde.org 

For the purposes of this document I will cover setting up both gnome and xfce in order to be started from KDM, to give a brief idea of how to go about changing window managers, and then I will move on to setting up two versions of KDE to allow concurrent use. 

 
Step 1 COMPILE

Grab the source for the window manager you wish to compile. Compile it, and install it. Ensure that wherever the binary lives, that it is in your PATH. Also 
you may if installing to /usr/local (the default) have to add /usr/local/lib to your /etc/ld.so.conf depending on the distribution you are running. 

You can get the latest xfce source (3.4.0 at time of this writing)in both tarball or rpm format from 
 
 
 

Step 1a adding xfce without compiling

Download the xfce-3.1.2-1.i386.rpm for your distribution. rpmfind can be helpful in finding one. Also SuSe ships with the latest version so if your using 
SuSe you already have it. Alternately generic rpm packages can be found at from 

http://www.xfce.org/download.html

Do 

rpm -ivh Xfce.(version).i386.rpm 

which should end with the no error messages. If you do receive an error message it's probably a result of failed dependencies and you will have upgrade to 
the required libraries. 

CONGRATULATIONS ! You've got XFce setup on your computer ! 

Now execute 

xfce_setup 

to make XFce your default desktop environment, (even if you're upgrading from a previous version, this is also recommended), and restart your X session to 
enjoy XFce Desktop environment. 

Note this has to be done by each user who wishes to use XFce, in addition to adding the exec xfce line to $HOME/.xinitrc it sets up the necessary directory
structure in $HOME 
 
 

Step 2

Edit your /etc/X11/kdm/Xsession or depending on your distribution you may have to edit /etc/X11/xdm/Xsession file. You will see a section that looks like 
the following. 

if [ -n "$wm" ]; then 
    case $wm in 
    kde) [ -z "$KDEDIR" ] && 
        { 
            KDEDIR=/opt/kde; export KDEDIR 
            PATH=$KDEDIR/bin:$PATH 
        } 
    exec /etc/X11/xinit/kdeinitrc;; 
    failsafe) 
    exec xterm -geometry 80x24-0-0;; 
esac 

This is the section we want to add the new Window Manager to. Order does not 
matter, but I usually add the new ones after kde) and before failsafe) So lets do it: 

For xfce I use: 

xfce) 
exec /etc/X11/xinit/xfceinitrc 
;; 

For gnome I use the following, note the environment variable GNOMEDIR does not 
have to be set but I use it for other things too, so I set it here.: 

gnome) 

GNOMEDIR=/opt/gnome; export GNOMEDIR 
PATH=$GNOMEDIR/bin:$PATH 
exec /etc/X11/xinit/gnome 
;; 
 
 

Step 3

Now you have to make the init scripts for these session that you have added Basically the easiest way to do this is to edit the existing xinitrc file and then do 
a save as, but I will provide a full script next: 

Note the location of Xmodmap and Xresources in the following file, these may be in a different place on your system. I'm running XF4 so all configuration
files are now in /etc/X11. If your running an earlier version these may be in /usr/X11R6/lib instead.Also these init scripts can go almost anywhere, just make sure that the session section in the above points to the proper path. My preference is putting them in /etc/X11/xinit 

For xfce I use: 

#!/bin/bash 
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $ 
###xfceinitrc 
userresources=$HOME/.Xresources 
usermodmap=$HOME/.Xmodmap 
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources 
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap 

# merge in defaults and keymaps 

if [ -f $sysresources ]; then 
xrdb -merge $sysresources 
fi 

if [ -f $sysmodmap ]; then 
xmodmap $sysmodmap 
fi 

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

if [ -f $usermodmap ]; then 
xmodmap $usermodmap 
fi 

exec xfwm 

For gnome I use: 

#!/bin/bash 
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $ 
#gnome 
userresources=$HOME/.Xresources 
usermodmap=$HOME/.Xmodmap 
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources 
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap 

# merge in defaults and keymaps 

if [ -f $sysresources ]; then 
xrdb -merge $sysresources 
fi 

if [ -f $sysmodmap ]; then 
xmodmap $sysmodmap 
fi 

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

if [ -f $usermodmap ]; then 
xmodmap $usermodmap 
fi 
PATH=/opt/gnome/bin:$PATH 
export PATH 
exec gnome-session; 
 
 
 

Step 4

make the init script world readable and executable: 

chmod 755 xfceinitrc 
chmod 755 gnome 

Step 5

Log into KDE as root, and open the Control-Centre->Applications->Login Manager 

You will see a tab at the top labeled sessions. Add the session you created in 
the Xsession file to this. In the case of the example above that would be: 

xfce 
gnome 

choose apply. Now when you log out you will be able to choose your window 
manager from the pulldown menu. 

Setting Up KDE1 and KDE2 Concurrently

Now the part everyone has been waiting for I'm sure, how to use the above and set up kde 1.1.2 and kde 2 to exist concurrently. 

NOw that your somewhat familiar with how KDM controls login sessions through the Xsessions file, you will easily be able to set both versions of KDE up 
so that they not only exist concurrently but allow you to run apps from one under the other and vice versa. 

First lets start with what we'll have to add to /etc/X11/kdm/Xsession (or in some cases depending on your X install /etc/X11/xdm/Xsession. Note on a fresh 
install of XFree 4 or any version of X from XFree.org it will be the later file. 

The session definition for KDE2 should look as follows 

kde2) [ -z "$KDEDIR" ] && { 
           KDEDIR=/opt/kde2; export KDEDIR 
           PATH=$KDEDIR/bin:$PATH 
           } 
           exec /etc/X11/xinit/kde2initrc 
           ;; 

Now we have to set up the kde2initrc that is called in the session, below you will find the kde2initrc I use. You will also notice that it's very similar to the 
one for XFce and Gnome, except for the last five lines. So as you can see this is definately not rocket science. 
#!/bin/sh 
userresources=$HOME/.Xresources 
if [ x"$XWINHOME" != x ]; then 
XINIT_DIR=$XWINHOME/lib/X11/xinit 
else 
XINIT_DIR=/etc/X11/xinit 
fi 
sysresources=$XINIT_DIR/.Xresources 
userdefaults=$HOME/.Xdefaults 
# merge in defaults and keymaps 
if [ -x /lib/cpp ]; then 
XRDB=xrdb 
else 
XRDB="xrdb -nocpp" 
fi 
for res in ${sysresources}* $userresources $userdefaults ; do 
if [ -f $res ]; then 
$XRDB -merge $res 
fi 
done 
# check for space on /tmp and $HOME and for write access 
# error exit, if not 
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 
testfile=KDE_$$.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 
export PATH=/opt/kde2/bin:$PATH 
export LD_LIBRARY_PATH=/usr/lib/qt2 
export KDEDIR=/opt/kde2 
export KDEHOME=$HOME/.kde2 
exec $KDEDIR/bin/startkde 

Note my kde2 is installed to /opt/kde2 and my qt2 to /usr/lib/qt2, edit these two variables to point to the proper place in your directory structure. Also not
that the kde2 home is $HOME/.kde2 this is so that when you start KDE2 it won't overwrite and of your previous KDE settings. After your finished the
kde2initrc file you'll have to make it world readable and executable so chmod 755 it. 

Now some of you are saying to yourself well I don't use KDM, how do I set them up to run concurrently if I start in runlevel 3 or whatever runlevel the GUI 
login is for your distribution. well that is even easier cause then you only need to write two small files, and add the last five lines from the above kde2initrc 
to the beginning of your /opt/kde2/bin/startkde file. these two files will also allow you to run apps from version under the other and vice versa. First lets do 
the KDE1 file. 

#!/bin/sh 
unset KDEDIR 
unset QTDIR 
export KDEDIR=/opt/kde 
export QTDIR=/usr/lib 
export PATH=$KDEDIR/bin:$PATH 
export LD_LIBRARY_PATH=$KDEDIR/lib:$QTDIR/lib 

Now to do the KDE2 file which is basically the same but initiates different environment variables. 

#!/bin/sh 
unset KDEDIR 
unset QTDIR 
export KDEDIR=/opt/kde2 
export QTDIR=/usr/lib/qt2 
export PATH=$KDEDIR/bin:$PATH 
export LD_LIBRARY_PATH=$KDEDIR/lib:$QTDIR/lib 

Now copy both these files to somewhere where everyone will have read permissions, I put mine in /opt/kde2/bin 

Now if you've read this whole document your probably wondering when it's going to be over and you'll be done. Well you'll be happy to know that we're on 
the home stretch. All we have left to do is set up a couple aliases, these can either go in the global bashrc file so each user doesn't have to set them 
individually, or or you can require that each user edit their $HOME/.bashrc file for themselves and add it. My preference was to add it to the global 
definitions, to make it a system wide alias. so add the following where you think it belongs on your system. 

alias dokde1='source /opt/kde2/bin/kde1' 
alias dokde2='source /opt/kde2/bin/kde2' 

Now if your using KDM as a login manager you will have to add the kde2 choice to it. You do this in the same way you added gnome and xfce above. 

Log into KDE as root, and open the Control-Centre->Applications->Login Manager 

You will see a tab at the top labeled sessions. Add the session you created in 
the Xsession file to this. In the case of kde2 that would be: 

kde2 

choose apply. Now when you log out you will be able to choose your window 
manager from the pulldown menu. 

If your not running KDM and typically login in from a text console edit your $HOME/.xinitrc and add the line exec startkde if not already there. Now when 
you login all you have to do is execute the proper alias, and then type startx. For example if you want to do KDE2 then you would type dokde2 and then startx

To run apps from one version under the other you will have to open a term window, or konsole or whatever your favorite terminal application is, and type 
the relevant dokde command, then hit enter, and then the executable you wish to run. Included here for your convenience are all the necessary files. But it's 
probably best to set it up for yourself from the start to hopefully avoid Murphy rearing his ugly head. 

-Jordan