I installed KDE desktop on my Ubuntu:

root@DESKTOP:/var/log# dpkg -l|fgrep -i kde-plasma-desktop
ii  kde-plasma-desktop                      5:63ubuntu16                               the KDE Plasma Desktop and minimal set of applications
root@DESKTOP:/var/log# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.04
Release:    11.04
Codename:   natty

I just wanted to know that if I press "CTRL+ALT+L" then what is the process/application that locks the screen? under GNOME it's gnome-screensaver. What is it under KDE?

  • I am commenting because I dont use KDE but I see a module called kscreensaver may be you should ps aux that Sep 14, 2011 at 10:13

1 Answer 1


For systems running KDE 4.x that will be

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock

For Ubuntu / Gnome: qdbus org.gnome.ScreenSaver /ScreenSaver Lock

Qdbus as written above, just sends a message on the message bus, which the screen-locker receives. The command will however lock the screen. qdbus just asks nicely "will someone lock the screen please?" The advantage of using qdbus, is that it is supported on other platforms than KDE. The text below works for KDE4 only.

Now watch and learn :o)

To figure this out in a little more detail, a bit of bash trickery is required:

  • list all processes while unlocked ps -ef;
  • lock the screen qdbus ..........;
  • wait a moment to get the screen locked sleep 1
  • then list the processes while locked ps -ef
  • find the differences between the output of both commands diff <( cmd1 ) <( cmd2 )

The command line:

diff <( ps -ef ) <( qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock; sleep 1; ps -ef )

< jhendrix 17088 16352  0 21:11 pts/4    00:00:00 /bin/bash
< jhendrix 17091 17088  0 21:11 pts/4    00:00:00 ps -ef
< jhendrix 17092 17089  0 21:11 pts/4    00:00:00 qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
> jhendrix 17093  2801 11 21:11 ?        00:00:00 /usr/lib/kde4/libexec/kscreenlocker --forcelock
> jhendrix 17095 17093 11 21:11 ?        00:00:00 kblankscrn.kss -root
> jhendrix 17099 17089  0 21:11 pts/4    00:00:00 ps -ef

This narrows down the list of potential commands to lock the screen, doesn't it? Now the answer to your question is simple: To lock the screen from the commandline use: /usr/lib/kde4/libexec/kscreenlocker --forcelock the blankscrn.kss is a child process of kscreenlocker, so kscreenlocker is the one to run.

To view the command syntax: /usr/lib/kde4/libexec/kscreenlocker --help

What it does? It basically draws a big black window that covers the whole screen and it forces it to be on top of everything. It catches all keystrokes and pops up a login dialog.

Finally which package does it come in (kde-workspace-bin)?

$ dpkg -S /usr/lib/kde4/libexec/kscreenlocker

kde-workspace-bin: /usr/lib/kde4/libexec/kscreenlocker

  • That <() is a neat trick! Sep 10, 2012 at 13:02
  • qdbus seems to be broken under Saucy, but it works if you install the package qdbus-qt5. Nov 14, 2013 at 10:10
  • Love the diff processers technique! I used a similar thing, but manually selected lock from the menu while it was sleeping (i.e. diff <( ps -ef ) <( sleep 3; ps -ef ) Nov 26, 2014 at 14:06
  • Instead of writing the script, you can just switch TTY with ctrl+alt+F# while screen is locked and grep processes there. But script is cool!
    – Grief
    Feb 18, 2017 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.