How to replace Xscreensaver with i3lock in Manjaro XFCE

Manjaro, like any other XFCE- based distribution, relies on Xscreensaver for its screen locking / saving needs. Xscreensaver was created in 1992, and that’s exactly what it looks like, making every log on an unpleasant flashback to the dark ages of Fvwm and Gnome 1.0.

So I started looking for an alternative, and finally found i3lock, a simple but elegant screen locker that goes really well with Manjaro, especially if you set the background color to black.

To use i3lock for automatic locking with xfce4-power-manager, you have to trick XFCE first into supporting it. Theoretically you could modify the xflock4 script, but your changes might be overwritten with the next XFCE update, so I decided to mask i3lock as slock, an even more minimalistic locker which is supported by XFCE. All I had to do was to create an executable file called slock in /usr/bin and enter the following text:

#! /bin/bash
i3lock -c000000

From now on, typing ‘slock’ will trigger i3lock with black background. After uninstalling Xscreensaver, xflock4 will now fall back to slock, with “lock on lid close” and all other xfce4-power-manager settings still working.

What’s still missing now is a real screensaver option, i.e. running i3lock after some idle time. This can be achieved using xautolock. To lock your screen after 7 minutes, add the following command to Settings / Session and Startup / Application Autostart

xautolock -locker xflock4 -time 7 -corners 0-00

The “corners” option tells xautolock NOT to lock your screen when the mouse cursor is in the upper right corner of the screen, which is a good way to prevent locking while watching movies.

This little guide is for Manjaro Linux XFCE, but it should work pretty much the same with vanilla Arch + XFCE or any other XFCE based distro, like Xubuntu, Mint XFCE or LMDE. And you should be able to get it to work for LXDE or Cinnamon, too, if you use xfce4-power-manager.