Stand With Ukraine

Wednesday, April 2, 2025

Setting up a screen lock with i3 on lightdm

As you might know there are many basic things, which are done automatically for you by GNOME and KDE, you have to do with i3 window manager yourself. One such thing is the screen locking functionality. If you are using lightdm login manager then there is a nice way to make it in the following manner:

# install the light locker (for arch-based distros)
yay light-locker
  
# add the following lines to your ~/.config/i3/config
exec_always --no-startup-id /usr/bin/light-locker
bindsym $mod+l exec --no-startup-id light-locker-command --lock
The last line is needed to be able to lock the screen with $mod+l combination. My $mod=Win, so I get to lock my screen with Win+l.

What I like about this approach is that it brings you to the lightdm login window, which is how I expected the locking to behave before I started using i3.