Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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?

share|improve this question
I am commenting because I dont use KDE but I see a module called kscreensaver may be you should ps aux that –  sagarchalise Sep 14 '11 at 10:13

1 Answer 1

up vote 19 down vote

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

share|improve this answer
That <() is a neat trick! –  Martin Ueding Sep 10 '12 at 13:02
qdbus seems to be broken under Saucy, but it works if you install the package qdbus-qt5. –  Mechanical snail Nov 14 '13 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 ) –  Matthew Wilcoxson Nov 26 '14 at 14:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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