Setting up autolock on i3

i3wm comes with a very nice screenlock called i3lock but as you might expect every thing is trimmed down and looks quite ugly by default. Also, it doesn’t have the feature of auto screen locking which I always felt is vital.

One funny morning I decided to look on the internet how people have modified the lock screens.

Here is the screenshot of my locked display -

Screenlocked

Looks cool, right ? Basically its the screenshot of whatever I am working on and after that I pixelate the screenshot by about 10%

For doing this I have a handy bash script which does the job pretty well. Below script takes the screenshot, stores it in /tmp and then creates another image which is pixellated by 10% for privacy reasons. This script also turns the display off after some time of inactivity.

#~/bin/sh -e

#fuzzylock.sh

# take a screenshot
scrot /tmp/screen_locked.png

# pixelate it 10x
mogrify -scale 10% -scale 1000% /tmp/screen_locked.png

# lock screen displaying this image
i3lock -i /tmp/screen_locked.png

# Turn off the screen after a delay
sleep 60; pgrep i3lock && xset dpms force off

EDIT - One obvious bug is that it doesn’t delete the original screenshot taken which is stored in /tmp

Package scrot generally comes installed by default on most distros and is available in almost all of the repos. mogrify program is part of ImageMagick which you will need to install.

Now we want this script to get executed manually and automatically as well after some time, for this I installed xautolock , configuring xautolock is pretty straightforward.

I added the following couple of lines in my i3 config file -

# for automatic screenlocking
bindsym $mod+q exec "~/dev/fuzzylock.sh"
exec xautolock -time 15 -locker "~/dev/fuzzylock.sh"

The time parameter takes the time in minutes before executing the script. While the first line defines a custom shortcut for executing the script.

That’s it for now. Next post will be about configuring proxies and 802.1x authentication on Arch Linux and a neat hack for making it work with google chrome. Happy Learning!

Comments