The i3-wm does not come with a keybinding to lock the screen or a preconfigured auto lockscreen. This gist describes how to setup both using i3lock and xautolock. i3lock is a minimalistic lockscreen and xautolock monitors mouse and keyboard activities to automatically lock the screen after a certain time of beiing inactive.
First get the tools if neccessary.
E.g. sudo apt install i3lock xautolock
.
To setup the keybinding Ctrl+Alt+l (last one is a lowercase L) to lock the screen append the following lines to the i3 configuration file located at ~/.config/i3/config
.
# keybinding to lock screen
bindsym Control+Mod1+l exec "i3lock -c 000000"
-c 000000
makes the screen turn black instead of the default white after the screen is locked.
Then add a line to the same config file to run xautolock at startup.
# auto lock the screen
exec "xautolock -detectsleep -time 3 -locker \"i3lock -c 000000\""
-detectsleep
locks the screen properly when the computer goes to sleep, -time 3
sets the time after which to lock to 3 minutes and -locker "..."
sets up i3lock as the command to lock.
Finally reload the config file via $mod+Shift+r
.
Thank you! It works like a charm.