1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6<refentry id="systemd-suspend.service"
7    xmlns:xi="http://www.w3.org/2001/XInclude">
8
9  <refentryinfo>
10    <title>systemd-suspend.service</title>
11    <productname>systemd</productname>
12  </refentryinfo>
13
14  <refmeta>
15    <refentrytitle>systemd-suspend.service</refentrytitle>
16    <manvolnum>8</manvolnum>
17  </refmeta>
18
19  <refnamediv>
20    <refname>systemd-suspend.service</refname>
21    <refname>systemd-hibernate.service</refname>
22    <refname>systemd-hybrid-sleep.service</refname>
23    <refname>systemd-suspend-then-hibernate.service</refname>
24    <refname>systemd-sleep</refname>
25    <refpurpose>System sleep state logic</refpurpose>
26  </refnamediv>
27
28  <refsynopsisdiv>
29    <para><filename>systemd-suspend.service</filename></para>
30    <para><filename>systemd-hibernate.service</filename></para>
31    <para><filename>systemd-hybrid-sleep.service</filename></para>
32    <para><filename>systemd-suspend-then-hibernate.service</filename></para>
33    <para><filename>/usr/lib/systemd/system-sleep</filename></para>
34  </refsynopsisdiv>
35
36  <refsect1>
37    <title>Description</title>
38
39    <para><filename>systemd-suspend.service</filename> is a system
40    service that is pulled in by <filename>suspend.target</filename>
41    and is responsible for the actual system suspend. Similarly,
42    <filename>systemd-hibernate.service</filename> is pulled in by
43    <filename>hibernate.target</filename> to execute the actual
44    hibernation. Finally,
45    <filename>systemd-hybrid-sleep.service</filename> is pulled in by
46    <filename>hybrid-sleep.target</filename> to execute hybrid
47    hibernation with system suspend and pulled in by
48    <filename>suspend-then-hibernate.target</filename> to execute system suspend
49    with a timeout that will activate hibernate later.</para>
50
51    <para>Immediately before entering system suspend and/or
52    hibernation <filename>systemd-suspend.service</filename> (and the
53    other mentioned units, respectively) will run all executables in
54    <filename>/usr/lib/systemd/system-sleep/</filename> and pass two
55    arguments to them. The first argument will be
56    <literal>pre</literal>, the second either
57    <literal>suspend</literal>, <literal>hibernate</literal>,
58    <literal>hybrid-sleep</literal>, or <literal>suspend-then-hibernate</literal>
59    depending on the chosen action. An environment variable called <literal>SYSTEMD_SLEEP_ACTION</literal>
60    will be set and contain the sleep action that is processing. This is primarily helpful for
61    <literal>suspend-then-hibernate</literal> where the value of the variable will be <literal>suspend</literal>, <literal>hibernate</literal>,
62    or <literal>suspend-after-failed-hibernate</literal> in cases where hibernation has failed.
63    Immediately after leaving system suspend and/or hibernation the
64    same executables are run, but the first argument is now
65    <literal>post</literal>. All executables in this directory are
66    executed in parallel, and execution of the action is not continued
67    until all executables have finished.</para>
68
69    <para>Note that scripts or binaries dropped in
70    <filename>/usr/lib/systemd/system-sleep/</filename> are intended
71    for local use only and should be considered hacks. If applications
72    want to react to system suspend/hibernation and resume,
73    they should rather use the <ulink
74    url="https://www.freedesktop.org/wiki/Software/systemd/inhibit">Inhibitor
75    interface</ulink>.</para>
76
77    <para>Note that <filename>systemd-suspend.service</filename>,
78    <filename>systemd-hibernate.service</filename>, <filename>systemd-hybrid-sleep.service</filename>, and
79    <filename>systemd-suspend-then-hibernate.service</filename> should never be executed directly. Instead,
80    trigger system sleep with a command such as <command>systemctl suspend</command> or <command>systemctl
81    hibernate</command>.</para>
82
83    <para>Internally, this service will echo a string like
84    <literal>mem</literal> into <filename>/sys/power/state</filename>,
85    to trigger the actual system suspend. What exactly is written
86    where can be configured in the [Sleep] section
87    of <filename>/etc/systemd/sleep.conf</filename> or a
88    <filename>sleep.conf.d</filename> file. See
89    <citerefentry><refentrytitle>systemd-sleep.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
90    </para>
91  </refsect1>
92
93  <refsect1>
94    <title>Options</title>
95
96    <para><command>systemd-sleep</command> understands the
97    following commands:</para>
98
99    <variablelist>
100      <xi:include href="standard-options.xml" xpointer="help" />
101      <xi:include href="standard-options.xml" xpointer="version" />
102
103      <varlistentry>
104        <term><option>suspend</option></term>
105        <term><option>hibernate</option></term>
106        <term><option>suspend-then-hibernate</option></term>
107        <term><option>hybrid-sleep</option></term>
108
109        <listitem><para>Suspend, hibernate, suspend then hibernate, or put the
110        system to hybrid sleep.</para>
111        </listitem>
112      </varlistentry>
113    </variablelist>
114  </refsect1>
115
116  <refsect1>
117    <title>See Also</title>
118    <para>
119      <citerefentry><refentrytitle>systemd-sleep.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
120      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
121      <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
122      <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
123      <citerefentry><refentrytitle>systemd-halt.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
124    </para>
125  </refsect1>
126
127</refentry>
128