I recently came across xsecurelock. It is an alternative to xscreensaver and other lockscreens, which focuses on security.

Out-of-the-box it just render a black screen as lockscreen, but with some configuration and elbow grease it is possible to make it pretty similar to i3lock-fancy – at least the “blurry desktop” part of it.

The script requires a few dependencies, namely mpv, imagemagick and scrot. They are all part of the standard repositories in Arch Linux, including xsecurelock, and can be installed using pacman: pacman -S mpv imagemagick scrot xsecurelock.

set -euo pipefail

LOCKSCREEN_DIR=~/.cache # this dir must contain a dir called 'lockscreen'
BLURTYPE="0x8" 		#

export XSECURELOCK_SAVER=saver_mpv
export XSECURELOCK_LIST_VIDEOS_COMMAND="find ${LOCKSCREEN_DIR}/lockscreen/ -type f"

if [ -z ${LOCKSCREEN_DIR+x} ]; then exit 1; fi # bail if lockscreen dir is not set

scrot ${LOCKSCREEN_DIR}/lockscreen-plain.png --overwrite && 
convert ${LOCKSCREEN_DIR}/lockscreen-plain.png -blur $BLURTYPE ${LOCKSCREEN_DIR}/lockscreen-blurred.png &&
mv ${LOCKSCREEN_DIR}/lockscreen-blurred.png ${LOCKSCREEN_DIR}/lockscreen/lockscreen.png &
xsecurelock &&
rm  ${LOCKSCREEN_DIR}/lockscreen/lockscreen.png

The script does the following:

  • it snap a screenshot using scrot
  • blurs it using imagemagick’s convert command
  • moves the image to an empty lockscreen directory since xsecurelock will use all images it finds in that specific directory
  • launches xsecurelock with XSECURELOCK_LIST_VIDEOS_COMMAND set so that it reads and displays the image as background
  • finally removes the plain (non-blurred) image

The first three steps are done sequentially, while xsecurelock is launched in parallel immediately since the blur operation takes a few seconds to complete.

This means that the lockscreen will activate the same moment you call the script, even though it takes a while before the background image is done rendering.

Unfortunately this results in a black screen for the duration that imagemagick renders the blur effect. Personally I can live with that, but there is obviously room for improvement.


As for xsecurelock, I enjoy these env variables too. Especially the kaomoji part:

export XSECURELOCK_FONT=JetBrainsMono

Prompt look I just realised that JetBrains Mono is missing some of the characters. Oh well…