FS#54690 - [systemd] Systemd breaks a sleep hook

Attached to Project: Arch Linux
Opened by Ganesh Ajjanagadde (gajjanag) - Tuesday, 04 July 2017, 13:48 GMT
Last edited by Dave Reisner (falconindy) - Monday, 07 January 2019, 11:29 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Dave Reisner (falconindy)
Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Systemd 232-8 breaks a sleep hook.

Additional info:
* systemd 232-8 onwards

Steps to reproduce:
1. Place the following service file as /etc/systemd/system/sleep.target.wants/i3lock-sleep.service
(user name modified accordingly):
[Unit]
Description=i3lock
Before=sleep.target

[Service]
User=gajjanag
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 000000

[Install]
WantedBy=sleep.target

2. Install i3lock via "sudo pacman -S i3lock".
3. Run "systemctl enable i3lock-sleep.service".
4. Run "systemctl suspend".

Screen was successfully locked in systemd 232-7 while laptop gets suspended,
but in 232-8 onwards the laptop suspends without the screen locking up.
This task depends upon

Closed by  Dave Reisner (falconindy)
Monday, 07 January 2019, 11:29 GMT
Reason for closing:  Not a bug
Additional comments about closing:  .wants directories are meant to have symlinks, not real unit files.
Comment by Christian Hesse (eworm) - Tuesday, 04 July 2017, 21:36 GMT
To be honest... I do not expect this to work. Did it?

Have you tried to put this in /etc/systemd/user/? Then drop the User= and Environment= lines and enable with:
systemctl --user enable i3lock-sleep.service

Did not test, but chances are...
Comment by Christian Hesse (eworm) - Tuesday, 04 July 2017, 21:38 GMT
If it still fails... Would be nice to have some error messages. ;)
Comment by Ganesh Ajjanagadde (gajjanag) - Wednesday, 02 August 2017, 15:09 GMT
Sorry for the delay.

Yes, this did previously work (i.e up to and including 232-7).
Above idea does not work.
I managed to work around this by simply moving the file via:
mv /etc/systemd/system/sleep.target.wants/i3lock-sleep.service /etc/systemd/system/i3lock-sleep.service

As for error messages, there are none as revealed by journalctl.
Basically, in 232-7, a message was logged saying "starting i3lock-sleep..." while suspending.
For 232-8 onward, no such message was logged, suggesting that for whatever reason, systemd was not reading this .service file.
As mentioned above, moving the file works around this issue.

Loading...