Kubuntu Karmic Koala and xscreensaver

If you have been playing with kubuntu since they switched over to KDE4 in Jaunty, you will have noticed that there's not much of a selection in screensavers.

I was able to find information on how to get xscreensaver set up and working as it should in 9.04.  After upgrading to the beta of 9.10 those instructions aren't exactly the same.  If anyone else has run across the problem of setting up xscreensaver on Karmic, here's how to do it using the terminal.

After turning off the default screensaver in System Settings, enter:

sudo mkdir /usr/share/backgrounds

This step cuts down on some errors you will get if the directory doesn't exist.  It can be changed in the xscreensaver config to point to a different location later, but you will get quite a few annoying warnings if you don't do it first.  Now install the packages:

sudo apt-get install xscreensaver*

Once that has all installed, you should be able to launch the xscreensaver config from your K menu.  Now we have to launch the xscreensaver at startup.  Create a file in ~/.kde/Autostart called xscreensaver.desktop and paste this into it:

[Desktop Entry]
Exec=xscreensaver -nosplash
Name=XScreenSaver
Type=Application
X-KDE-StartupNotify=false

Now the last thing that needs to happen is replacing the built-in screenlocker so that it launches xscreensaver instead.  cd to /usr/lib/kde4/libexec and run this:

sudo mv kscreenlocker kscreenlocker.bak

Create a file called kscreenlocker in the same location.  Paste in the following and save:

#!/bin/sh
xscreensaver-command -lock

Finally, make it executable by running the following command and you are done!

sudo chmod +x kscreenlocker