Using i3lock with systemd-suspend | Hund


Using i3lock with systemd-suspend

Tuesday, January 8, 2019

This is a remake of a few days old post [Commit: 83ac8455]. I shouldn't make posts when I'm that tired. :)

It took me a few tries before figuring this one out. But I eventually found the [the easy] solution in an old thread on the Arch Linux forums [Link].

I started out by creating the file /etc/systemd/system/i3lock.service with the following content:

Description=Lock screen before suspend



I then enabled the service with the command:

# systemctl enable i3lock.service

That’s it! And for those curious, this is what my looks like:



# Take a screenshot for our background
scrot $img
# Pixelate the background
convert $img -scale 10% -scale 1000% $img
# Add the lock-icon
convert $img $icon -gravity center -composite $img
# Finally run i3lock itself
i3lock -u -i $img

It will now lock my screen before it goes to sleep, so it’s locked when it wakes up again.