Skip to content

I3 fuzzy lock and suspend

Install packages.

sudo apt install imagemagick scrot
Create fuzzy_lock.sh file.
~/.config/i3/fuzzy_lock.sh
#!/bin/sh -e

rm -f /tmp/screen_locked.png

# Take a screenshot
scrot /tmp/screen_locked.png

# Pixellate it 10x
mogrify -scale 25% -scale 400% /tmp/screen_locked.png

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

# Optionally suspend.
if [ "$1" == "suspend" ]; then
  systemctl suspend
fi
Make it executable.
chmod +x ~/fuzzy_lock.sh
Create suspend.sh file.
~/.config/i3/suspend.sh
#!/bin/bash
/home/tdgraaff/.config/i3/fuzzy_lock.sh
systemctl suspend
Add the following lines to the i3 config.
~/.config/i3/config
bindsym control+mod1+l exec /home/tdgraaff/.config/i3/fuzzy_lock.sh
bindsym control+mod1+s exec /home/tdgraaff/.config/i3/suspend.sh
exec --no-startup-id xautolock -detectsleep -time 5 -locker /home/tdgraaff/.config/i3/fuzzy_lock.sh -killtime 60 -killer "systemctl suspend" &

Press Modifier+Shift+c to reload the i3 config. Press Ctrl+Alt+l to lock the screen, and Ctrl+Alt+s to suspend. The screen will autolock after 15 minutes and the system will suspend automatically after an hour.

Back to top