Skip to content

Instantly share code, notes, and snippets.

@simonfontana
Last active March 23, 2022 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonfontana/180f36c69a3d708e88bea605a1225b2f to your computer and use it in GitHub Desktop.
Save simonfontana/180f36c69a3d708e88bea605a1225b2f to your computer and use it in GitHub Desktop.
Lock screen after suspend with i3lock and systemd
# file /etc/systemd/system/wakelock.service
[Unit]
Description=Lock the screen on resume from suspend
Before=sleep.target suspend.target
[Service]
User=%i
Type=forking
Environment=DISPLAY=":1"
ExecStart=/usr/bin/i3lock --color='#111111'
[Install]
WantedBy=sleep.target suspend.target
# Note that my DISPLAY is set to :1. You can verifiy what display you're using with `echo $DISPLAY`.
# You can of course change _ExecStart_ to whatever lock service you prefer.
# Save the file, then enable and reload systemd:
# `sudo systemctl enable wakelock@$(whoami).service && sudo systemctl daemon-reload`
# Verify that the service is loaded (it won't become active until you suspend):
# `systemctl status wakelock@$(whoami).service`
# Reference: [Lock screen after suspend with i3lock and systemd](https://gist.github.com/victorhaggqvist/603125bbc0f61a787d89)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment