Bug 80082 - Suspend/Hibernate should have StopWhenUnneeded=yes
Summary: Suspend/Hibernate should have StopWhenUnneeded=yes
Status: RESOLVED INVALID
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-16 07:43 UTC by m8r-0s9a4g
Modified: 2014-06-25 04:11 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description m8r-0s9a4g 2014-06-16 07:43:44 UTC
I want to have a unit that starts/stops on suspend (but not hibernate).

Using WantedBy=sleep.target works for suspend or hibernate, but WantedBy=suspend.target will not work because systemd-suspend.service doesn't have StopWhenUnneeded=yes.

Is there any downside to add StopWhenUnneeded to suspend? Is there any other way to have a service stop/stop based on suspend that I'm missing?
Comment 1 Lennart Poettering 2014-06-20 11:58:51 UTC
Not following here. systemd-suspend.service terminates as soon as the suspend is complete, on its own, because it does exit(0), there's no point of adding StopWhenUnneeded=yes to it. Don't grok the problem.

Your service should be able to do BindTo=systemd-suspend.service and Before=systemd-suspend.service. That way, its ExecStart= should be invoked before, and its ExecStop= after the suspend.

Also note the hook directory in /usr/lib/systemd/system-sleep/. See systemd-sleep(8) for details.
Comment 2 m8r-0s9a4g 2014-06-25 04:11:23 UTC
Looks like BindsTo=systemd-suspend.service and Before=systemd-suspend.service does what I want.

I guess my confusion is why does suspend.target stay active after resuming when sleep.target doesn't?

I don't think I'm the only one confused by it. The Arch wiki[1] has examples with suspend.target and sleep.target. I don't think the suspend.target ones will work as expected.

[1] https://wiki.archlinux.org/index.php/Power_management#Suspend.2Fresume_service_files


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.