You are not logged in.
Pages: 1
Topic closed
Suspend on lid close works just fine, but I cannot get the systemd service file to lock the screen on suspend working. I have seen numerous guides and .service files to do this, but I must be missing something. Below is my .service file, but when I start it the screen locks immediately and then the service fails. It never runs when I close the lid, or run "systemctl suspend". If anyone can help me figure out what I am doing wrong I would really appreciate it.
Note: I have tried xautolock, as below as well as "dm-tool lock". I have tried both suspend.target and sleep.target. Most of the guides I have seen show sleep.target, but I don't seem to have that target (see below). Also, the etc/systemd/logind.conf file has "HandleLidSwitch=suspend". As far as I can tell, acpid is not running and pm-utils is not even installed. The desired effect is the locker (any really) is called when the computer suspends.
Service File lidlock.service
[Unit]
Description=Lock X session on lid switch
After=suspend.target
[Service]
User=james
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/xautolock -locknow
[Install]
WantedBy=suspend.target
Output of "systemctl list-units --type=target"
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
bluetooth.target loaded active active Bluetooth
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
network.target loaded active active Network
paths.target loaded active active Paths
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
sound.target loaded active active Sound Card
suspend.target loaded active active Suspend
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
Last edited by jkav77 (2014-08-05 19:50:22)
Offline
You aren't calling a locker...
This works for me:
[Unit]
Description=Lock the screen on resume from suspend
[Service]
User=jason
Environment=DISPLAY=:0
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
Offline
I have used "xautolock -locknow", "dm-tool lock" and I installed slock to duplicate your setup. I ran the exact service file you posted, except I changed the username. When I started that service, the screen went blank briefly and then returned to the console. The service failes (see below). I am not really sure where to look for information about what the problem is. The journal does not contain any more information than the service status below.
sudo systemctl status -l lidlock2 output:
● lidlock2.service - Lock the screen on resume from suspend
Loaded: loaded (/etc/systemd/system/lidlock2.service; disabled)
Active: failed (Result: exit-code) since Mon 2014-08-04 19:04:32 PDT; 43s ago
Process: 30232 ExecStart=/usr/bin/slock (code=exited, status=1/FAILURE)
Main PID: 30232 (code=exited, status=1/FAILURE)
Aug 04 19:04:32 chrutabaga systemd[1]: lidlock2.service: main process exited, code=exited, status=1/FAILURE
Aug 04 19:04:32 chrutabaga systemd[1]: Unit lidlock2.service entered failed state.
service file (same as you gave me):
[Unit]
Description=Lock the screen on resume from suspend
[Service]
User=james
Environment=DISPLAY=:0
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
Offline
If slock is working, then I am not sure why the service would be failing. You did test it outside the service file?
Offline
Yes. If I run it outside the service file it works as normal. Black screen, turns blue when you start typing; unlocks when password entered. But for some reason the service is not working, and the error messages are very generic. I am not sure what to look at.
Offline
What does `systemctl list-units | grep lidlock` show?
Offline
It fails right away. I'm not sure why.
systemctl list-units | grep lidlock
55:●lidlock2.service loaded failed failed Lock the screen on resume from suspend
Offline
I'm at a loss. Remove all the service files/symlinks and start from scratch.
Offline
jkav77,
I also found calling a locker (e.g., xautolock, slock) from a .service file in combination with suspend via lid closing to be hit-and-miss. I ended up using:
xss-lock
from the AUR and it works as expected on wake from suspend. Its autostarted from the i3 config file (mod for your own context) like:
exec --no-startup-id xss-lock -- i3lock -b -i /path/to/archlinux.png &
So try clearing out all locker-related service files/symlinks, install xss-lock and give it a try.
4X Intel(R) Xeon(R) CPU E7-8870 @ 2.40GHz; 256GiB; 11TB EXT4; SL6.8
2X Intel(R) Xeon(R) CPU E5-2680 @ 2.70GHz; 256GiB; 3.4TB EXT4; SL6.8
Thinkpad X250; Broadwell-ULT Core i5; 8GiB, 525GB Crucial_CT525MX3; Arch
Thinkpad T440S; Haswell-ULT Core i7; 12GiB, 512GB SanDisk X210; Arch
Offline
@halocaridina,
Thank you for pointing me to this util. This is now working with slock. However, it has the undesirable effect that the screen displays for 1-2 seconds after resume when using it with the lightdm locker (dm-tool lock). I will just abandon using that locker since this is now working and I don't want to put any more time into this. I added it to my .xprofile so it runs at startup.
Thanks for the help. I will mark this as solved.
.xprofile
xss-lock -- /usr/bin/slock &
Offline
The following works for me with "Type=forking". It seems that xss-lock is not necessary.
[Unit]
Description=i3 lock for suspension
[Service]
User=james
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -p win -d -c 000000
[Install]
WantedBy=sleep.target
Offline
Please don't necrobump, especially solved threads: https://wiki.archlinux.org/index.php/Fo … bumping.22
Closing
Offline
Pages: 1
Topic closed