Skip to content

Instantly share code, notes, and snippets.

@rometsch
Last active May 26, 2025 03:38
Show Gist options
  • Save rometsch/6b35524bcc123deb7cd30b293f2088d8 to your computer and use it in GitHub Desktop.
Save rometsch/6b35524bcc123deb7cd30b293f2088d8 to your computer and use it in GitHub Desktop.
Configure lockscreen for i3 window manager.

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.

@Alottachairs
Copy link

Alottachairs commented May 26, 2025

Try changing the directory to just Downloads/your-image.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment