Manjaro i3 Lock Screen When Lid Closed

10/18/20191 Min Read — In DevTools, Linux

When you close the lid on your laptop (using Manjaro i3), the laptop goes to suspend mode. But the screen doesn't lock.

You have to write a script for systemd.


Manjaro i3 ships with i3lock and a custom blur screen out of the box.
If you use this tool, you have to create a suspend script as etc/systemd/system/suspend@.service (with root):

Description=User suspend actions
ExecStartPost=/usr/bin/sleep 1

The service starts the blurlock script before the laptop goes to sleep mode.
With ExecStartPost=/usr/bin/sleep 1 we avoid a screen flash after you open the laptop lid.

Activate the service with:

sudo systemctl enable suspend@$USER


If you use betterlockscreen (install it via AUR), you can use their script:

sudo systemctl enable betterlockscreen@$USER

Further Reading