Since, I've switched to Awesome WM, I've been meaning to find a way to lock my X session.

What I want

I have an HTC One running ParanoidAndroid and one of my favorite features is the ability to set your lock screen wallpaper as a blurred see-through view of the underlying screen: this is exactly what I wanted to emulate.

What I needed

  1. i3lock
  2. scrot
  3. imagemagick
  4. xautolock

All four of these can be installed on Ubuntu through apt-get via

sudo apt-get install i3lock scrot imagemagick xautolock

How I did it

The way I approached this is by using scrot to take a screenshot, then use imagemagick to apply a Gaussian blur, finally run i3lock using the modified image as the background.

Create a new file /bin/lock (you'll need sudo to write) that contains

scrot /tmp/screenshot.png
convert /tmp/screenshot.png -blur 0x5 /tmp/screenshotblur.png
i3lock -i /tmp/screenshotblur.png

The first line takes a screenshot. The second line applies a Gaussian blur, the parameter is bias x radius, this what I liked but feel free to change it (note: the larger the radius, the longer it will take to process). The third line actually activates the lock screen.

Save the file and mark it as executable

sudo chmod +x /bin/lock

You can now run lock from bash to activate your brand new lock screen!


This is great, but it's useless unless our computer locks after inactivity. For this, I used xautolock that does just that. Add the following line wherever you keep your startup scripts (rc.lua, .bashrc, .xsessionrc, etc...)

xautolock -time 10 -locker lock

The first parameter denotes how long to wait, in minutes, before showing the lock screen and can range from 1 to 60. The second parameter is what to run, which should obviously be our new executable.

That's it

Looks pretty awesome huh?

Some further notes: i3lock has some other parameters you might want mess around with, check man i3lock

Even better note: shiver made an awesome fork of i3lock that includes a flag for blurring a screenshot of your desktop with no extra dependencies or writing to files, I definitely recommend it too (especially if you're running arch as the PKGBUILD is here).