Please enable JavaScript to view the self-hosted comments.
Andrew's personal blog to share his occasional IT/programming notes with the World.
Andrew Sichevoi is experienced Software Developer with more than 10 years of commercial development. Skilled in C++, Python, object oriented design and architecture, crossplatform development as well as in team leadership.

How to replace default screensaver in XFCE

· by Andrew Sichevoi · Read in about 2 min · (411 Words)
linux xfce

By default XFCE is shipped with a quite ascetic xscreensaver. Some people may find it not attractive. So I do also. For example, if you install an alternative screen locking application called i3lock there are about no chances that it will be used by XFCE. Even there are no other alternatives installed. Because XFCE knows nothing about it. But user definitely knows and wants to replace the default screensaver with a preferred one.

The entry point for XFCE to screen lockers is a script called xflock{4}. All XFCE applications which need to start a screensaver or to lock the screen run it. (Note: Since version 4.10 it is shipped as a part of xfce4-session package.) E.g., XFCE’s power manager will call xflock{4} when an action “Lock Screen” is specified for several ACPI events like “LID closed”; or when system goes suspend. The script itself launches only a default screensaver.

Possible alternatives

The ugly thing about this script is that it contains hardcoded list of screensavers. So if yours favorite screensaver is not listed there it won’t be launched. The priority of these locking applications is:

  1. xscreensaver
  2. GNOME Screensaver
  3. xlock
  4. slock

And nothing else!


The straight way is to add an alternative screensaver is to hack xflock{4}’s contents. Replace:

for lock_cmd in \
  "xlock -mode blank" \


for lock_cmd in \
  "my-favorite-screensaver" \ # e.g. i3lock
  "xlock -mode blank" \

But on the system’s next update these changes more likely will be overrided with the default ones and yours screensaver will stop launching. The best way of course is to extend xflock{4} and send the patch to upstream; but not this time :). Another way is to pretend like we have a one of the above-mentioned screensavers which XFCE is familiar with:

1. Create a script which launches your screensaver. For example, with the following contents:

if ! pidof i3lock > /dev/null 2>&1; then # launch once only
  /usr/bin/i3lock --dpms -c 000000

2. Make a symbolic link /usr/bin/slock to the newly created script;

After these steps there will be a new system’s default screen locker.

Note: Do not forget to uninstall xscreensaver, gnome-screensaver, xlock from the system if there are any to prevent using of them because of their’s higher priority.

Note: Please keep in mind about created symlink if once you decide to install an application with the same name.

This article was originally published on the previous version of this blog