Power Management: Difference between revisions
m Added a header to highlight systemctl cancel |
Replace deprecated sleep extraConfig option that was missed last edit |
||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 30: | Line 30: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
systemd.services.your-service-name = { | |||
description = "Service description here"; | |||
wantedBy = [ "post-resume.target" ]; | |||
after = [ "post-resume.target" ]; | |||
script = '' | |||
echo "This should show up in the journal after resuming." | echo "This should show up in the journal after resuming." | ||
''; | |||
serviceConfig.Type = "oneshot"; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 48: | Line 48: | ||
Therefore, an example configuration could look like this:<syntaxhighlight lang="nix"> | Therefore, an example configuration could look like this:<syntaxhighlight lang="nix"> | ||
/ | // I'm hibernating into a logical volume that's also under LUKS. Pretty cool, right? | ||
swapDevices = [ | swapDevices = [ | ||
| Line 69: | Line 67: | ||
== Tips and tricks == | == Tips and tricks == | ||
=== | === Hibernate after specified time === | ||
Using following configuration, your system will go from suspend into hibernate after 1 hour:<syntaxhighlight lang="nix"> | Using following configuration, your system will go from suspend into hibernate after 1 hour:<syntaxhighlight lang="nix"> | ||
systemd.sleep. | systemd.sleep.settings.Sleep = { | ||
HibernateDelaySec=1h | HibernateDelaySec = "1h"; | ||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Disable all sleep functionality === | |||
Some desktop environment and display manager combinations might attempt to put your machine to sleep as default behavior (i.e. SDDM and KDE Plasma 6 under Wayland). If this is not what you want, you can define the following to block any service attempting to put your machine to sleep via systemd: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
systemd.sleep. | systemd.sleep.settings.Sleep = { | ||
AllowHibernation = "no"; | |||
AllowHybridSleep = "no"; | |||
AllowSuspend = "no"; | |||
AllowSuspendThenHibernate=no | AllowSuspendThenHibernate = "no"; | ||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 200: | Line 201: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
In this case, the <code>pre-sleep-start</code> script referenced by <code>ExecStart</code> contained directives installed by the [[Displaylink]] package, that contained a flush operation which hung the suspend action. Starting <code>dlm.service</code> or running <code>sudo DisplayLinkManager</code> unblocks the script and made suspend work normally. | |||
==== Cancelling an existing suspend action ==== | ==== Cancelling an existing suspend action ==== | ||