An hacky trick to run KDE4 applications in a KDE3 session without messing stuff up

Warning: what I’m describing in this entry is an hacky, dirty trick which will not always work perfectly fine for you. Use it at your own risk.

Now that KDE4 is in portage, I wanted to try just a couple of applications, one being Umbrello, the other being Konqueror, even though I also tried GwenView (and that seems to me the most usable of the three 😉 ).

Unfortunately if you run a KDE4 application out of the box in a Gentoo system, it will mess stuff up with your config, and for instance KMail won’t be able to send mail anymore.

This is what I’ve done yesterday: first of all, I made sure that my default environment is the one for KDE 3.5:

cd /etc/env.d
ln -s 45kdepaths-3.5 40kdepaths-3.5

Afterward I prepared a copy of my .kde directory for the 4.0 slot:

rsync ~/.kde3.5 ~/.kde4.0/

(make sure you write the / after .kde4.0 or it’ll create ~/.kde4.0/.kde3.5)

Then I wrote this simple script:


export KDEHOME=~/.kde4.0
export PATH=/usr/kde/4.0/bin:${PATH}
export XDG_DATA_DIRS=/usr/kde/4.0/share:${XDG_DATA_DIRS}
export KDEDIRS=/usr/kde/4.0:${KDEDIRS}


/usr/kde/4.0/bin/$exec "$@"

At this point, running kde4 konqueror will bring me the konqueror from KDE4 rather than the one from 3.5, using is own settings, and without messing stuff up in my 3.5 installation (which I still daily use).

Just my two €.05 😉

Warning: this dirty, hacky trick is not supported by Gentoo developers, and most likely a good part of the Gentoo KDE team would like to kill me for just posting this 😛