Lock your KDE screen from the command line
Did you know you can lock your current KDE screen by using the command line? For the 3.x series use
dcop kdesktop KScreensaverIface lock
and for KDE 4.x try
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
With the help of these you should be able to craft a simple shell script that will lock your screen at given actions. For example, you can leave your screen unlocked and make the PC activate the commands above when it detects mouse movement or when a certain application is launched.