So: you’ve installed KDE 4 under the kde-devel user (following the instructions at TechBase). Now you want to try out KDE 4 in all its glory, but as your main user. Well, here’s how.
First of all, we’ll need a script that sets up the environment and starts KDE 4. /home/kde-devel/kde/bin/startkde does most of this, of course, but it expects some things set up first, like PATH. To this end, we’ll set up a couple of bash functions that give us a KDE environment. Create a file /home/kde-devel/bin/startkde4 with the following contents:
#!/bin/bash # startkde4 function removefrom() { local varname=$1 local entry="$2" unset newvar for value in `IFS=: eval echo \\$$varname`; do if [ "$value" != "$entry" ]; then newvar="${newvar}${newvar+:}${value}" fi done # Set it again eval $varname="$newvar" unset newvar } if [ -n "$QTDIR" ]; then removefrom PATH $QTDIR/bin removefrom LD_LIBRARY_PATH $QTDIR/lib removefrom PKG_CONFIG_PATH $QTDIR/lib removefrom MANPATH $QTDIR/man fi export QTDIR=/home/kde-devel/build/qt-copy export PATH=$QTDIR/bin:$PATH export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$QTDIR/lib:$PKG_CONFIG_PATH export MANPATH=$MANPATH:$QTDIR/man export QMAKESPEC=$QTDIR/mkspecs/linux-g++ # Remove the current KDE from variables if [ -n "$KDEDIR" ]; then removefrom PATH $KDEDIR/bin removefrom LD_LIBRARY_PATH $KDEDIR/lib removefrom PKG_CONFIG_PATH $KDEDIR/lib/pkgconfig fi # Add the new one export KDEDIR=/home/kde-devel/kde export KDEDIRS=$KDEDIR export KDEHOME=$HOME/.kde4 export KDETMP=${TMPDIR-/tmp}/kde4-$USER export KDEVARTMP=/var/tmp/kde4cache-$USER export KDE_DATA_DIRS=$KDEDIR/share export PATH=$KDEDIR/bin:$PATH export XDG_CONFIG_DIRS=$KDEDIR/etc/xdg export QT_PLUGIN_PATH=$KDEDIR/lib/plugins export LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$KDEDIR/lib/pkgconfig:$LD_LIBRARY_PATH export KDE_COLOR_DEBUG=1 # Ensure that they exist mkdir -p $KDEDIR $KDETMP $KDEVARTMP exec /home/kde-devel/kde/bin/startkde
Of course, you can turn most of this file into a bash function called kde4 and place it into your ~/.bashrc, then turn your terminal into a place to run kde4 apps from (in your kde3/gnome/whatever session) by typing “kde4″ at the prompt.
Now make sure it’s executable (chmod +x /home/kde-devel/bin/startkde4).
Finally, we need a session for KDE4. In /etc/X11, there should be a folder called sessions. This should contain kde.desktop. You can copy this to kde4.desktop and edit it to look like the following (ie: change the Name, Exec and TryExec):
[Desktop Entry] Encoding=UTF-8 Type=XSession Exec=/home/kde-devel/bin/startkde4 TryExec=/home/kde-devel/bin/startkde4 Name=KDE4 Comment=The K Desktop Environment. A powerful Open Source graphical desktop environment
Now you should be able to select “KDE4″ as the session type in KDM and log in to a KDE 4 session.