Skip to content

Instantly share code, notes, and snippets.

@raphiz
Created September 19, 2016 11:17
Show Gist options
  • Save raphiz/d69859645a9da08a0cf0778f42932120 to your computer and use it in GitHub Desktop.
Save raphiz/d69859645a9da08a0cf0778f42932120 to your computer and use it in GitHub Desktop.
Lock screen on suspend - i3 - /etc/systemd/system/
[Unit]
Description=User suspend actions
Before=sleep.target
[Service]
User=rzi # Replace with your user id - %I does not work somehow :/
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/blurlock # Or i3lock
ExecStartPost=/usr/bin/sleep 1
[Install]
WantedBy=sleep.target
@rbran
Copy link

rbran commented Dec 28, 2017

@reverendhomer There is a note in https://wiki.archlinux.org/index.php/Power_management#Suspend.2Fresume_service_files

As screen lockers may return before the screen is "locked", the screen may flash on resuming from suspend. Adding a small delay via ExecStartPost=/usr/bin/sleep 1 helps prevent this.

@kenoh
Copy link

kenoh commented Jan 27, 2018

%I would work if the service file name ended with @.service instead of .service. Then, you can enable it for a user: systemctl enable [email protected].

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