Locking the screen up in Xfce4


Xfce4 comes without any screensaver or utility that lets you lock the screen up. This is a security issue if you have to leave your computer alone for a while, for instance, when you go to break during class. I did a research and I found there’s a command for Xfce4 called xflock4 that locks your screen up, but it failed showing this message:

/usr/bin/xflock4: line 22: xlock: command not found

I didn’t want to install a screensaver but I had to, because it seems the lock function is only provided by a utility like gnome-screensaver or xsreensaver. Due to I’m not using Gnome I chose the latter.

Installing xscreensaver

On Debian you can install xscreensaver package as follow:

aptitude install xscreensaver

Starting xscreensaver

You can start xscreensaver by executing this command:


It will run in background as a daemon, checking for idleness to launch the screensaver or a command.

Locking the screen up

You can lock your screen up by executing the following command:

xscreensaver-command -lock

As far as now you have installed, run and invoked the screensaver, but how is all this related to Xfce?

Setting xscreensaver in Xfce4

You have to execute xscreensaver every time you log in into Xfce4, so you have to use Xfce4’s Session and startup feature. Just go to Applications  > Xfce Settings  > Session and startup and add the following:


The –no-splash option tells to xscreensaver not to splash the setting dialog box while starting in background.

Setting a shortcut

In Gnome you can use the keystroke Ctrl+Alt+L to lock the screen up (in Windows you can do the same by pressing  Windows button + L). If you want to have something like that in Xfce4 go to Applications > Settings > Xfce 4 Setting manager and  select the Keyboard icon.
There are add the shortcut with this command:

xscreen-command -xlock

By the way, after installing xscreensaver you will be able to use the xflock4 command…


  1. #1 by Luis Gallardo on 01/06/2013 - 10:40 am

    @unya thanks for the tip. Best regards!

  2. #2 by nunya on 01/06/2013 - 9:10 am

    Or one can add xflock4 to the keyboard shortcut instead of xscreensaver-command -lock

  3. #3 by Luis Gallardo on 12/10/2010 - 9:33 pm

    @Jason thanks for the suggestion, but I use Xfce + Slim because it’s lighter than Gnome + gdm. But Linux is about choices, so for those guys using gdm as their login manager gdmflexiserver is the command to use…


  4. #4 by Jason on 12/10/2010 - 9:10 pm

    Instead of using xscreensaver you could use;

    # gdmflexiserver

    if your using gdm…

Comments are closed.