Keywords: bash, KDE 4, KDE 3
Depends on: KDE
Lock your KDE session via the command line or use the Application Launcher to run this script. Credit, I believe, to Kevin K. I'm nearly certain he provided the magic juju beans for this script.
If you need to use this script with KDE 3, comment/uncomment the self-evident calls.