You are not logged in.

#1 2017-10-28 15:36:27

barefly
Member
Registered: 2014-08-16
Posts: 59

Locking screen after suspend

I have created a systemd service file, posted below, that I am using to start slock after suspend occurs. Currently though this is not working as when I check the status of my started service file I am seeing the following errors:
   

Oct 28 09:23:58 laptop systemd[1]: Started Lock screen after resume from suspend
Oct 28 09:23:58 laptop slock[20421]: No protocol specified
Oct 28 09:23:58 laptop slock[20421]: slock: cannot open display

This occurs even before I get a chance to test it out by running systemctl suspend. Below is my service file.

[Unit]
Description=Lock screen after resume from suspend
After=suspend.target

[Service]
Type=simple
#User=%i
Environment=DISPLAY=:0
ExecStart=/usr/bin/slock
#ExecStart=/usr/bin/i3lock

[Install]
WantedBy=suspend.target

I have tried with the User=%i line commented and uncommented. The above error occurs when commented, and below is the error I get when uncommented.

Oct 28 09:33:40 laptop systemd[1]: Started Lock screen after resume from suspend.
Oct 28 09:33:40 laptop systemd[25792]: resume@laptop.service: Failed to determine user credentials: No such process
Oct 28 09:33:40 laptop systemd[25792]: resume@laptop.service: Failed at step USER spawning /usr/bin/slock: No such process

Any help getting this to work would be appreciated.

Last edited by barefly (2017-10-28 15:39:50)

Offline

#2 2017-11-02 02:37:53

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,131

Re: Locking screen after suspend

Any particular reason you don't want to use the solution in the wiki https://wiki.archlinux.org/index.php/Slock?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB