15 April, 2014

Gaussian Blur Lock Screen - i3lock


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).


Gio d'Amelio15 April, 2014Super easy and looks great. Thanks
Rom Ockee17 April, 2014Wow, Nice! Thank you mate!
Pete20 April, 2014Depending on the type of stuff you have (or could have) on your screen, you may want to use shred or at least delete the original screenshot between the convert command and i3lock command. I used: shred -f --random-source="/dev/urandom" -u ~/lock-screenshot.png Which writes urandom to the file 3 times then deletes it.
Redd.Starr26 April, 2014Hey! When I run "xautolock -time 10 -locker lock", nothing seems to happen. It just sits there just hanging out, and it's been like that for an hour or so already. Every step was followed up until this point.

New comment