You are not logged in.
My goal is to always suspend-then-hibernate system-wide bc I don't use this laptop often and don't want it to run out of battery all the time.
I figured out a way to achieve this and wanted to share. Lmk if anyone thinks it's a bad idea!
TL;DR Overides the ExecStart value to suspend-then-hibernate
sudo mkdir /etc/systemd/system/systemd-suspend.service.d
print "[Service]\nExecStart=\nExecStart=/usr/lib/systemd/systemd-sleep suspend-then-hibernate" | sudo tee /etc/systemd/system/systemd-suspend.service.d/override.conf > /dev/null
sudo systemctl daemon-reload
@raynman also offered an approach which seems to work:
ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
Last edited by bdombro (2022-01-06 00:27:07)
Offline
Your change will be overwritten every time systemd is updated. You should use a drop-in file instead.
https://wiki.archlinux.org/title/System … ided_units
Offline
You can also just properly configure this via standard configuration: https://wiki.archlinux.org/title/Power_ … on_request
Offline
Thanks @slithery! I updated my post.
@V1del I couldn't figure out how to set those files correctly to do it system-wide. Do you have more specific instructions?
Offline
That's incorrect. The drop-in file should look like...
[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-sleep suspend-then-hibernate
But @V1dels answer is the correct approach and the wiki page they linked shows you exactly what to change.
Offline
Thanks friends! I really appreciate your help!
Forgive me, but I still don't understand how to set SuspendMode to automatically suspend-then-hibernate. According to the docs,
> systemd-suspend-then-hibernate.service(8) uses the value of SuspendMode= when suspending and the value of HibernateMode= when hibernating.
Doesn't that mean suspend will call suspend-then-hibernate, which will in turn call suspend->suspend-then-hibernate in an infinite loop? When I try setting `SuspendMode=suspend-then-hibernate`, the system blocks me from suspending:
```
> sudo systemctl suspend
Failed to suspend system via logind: Sleep verb "suspend" not supported
```
Offline
I might be missing something, but that wiki section is about hybrid-sleep, not suspend-then-hibernate.
Idea for an alternative to the override:
# ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
Offline
@Raynman yeah I thought about that too, but I suspect it won't work bc suspend-then-hibernate literally calls suspend, if I understand correctly. So that would create an infinite loop.
Also see my last comment :-)
Offline
I might be missing something, but that wiki section is about hybrid-sleep, not suspend-then-hibernate.
What's the difference? I always thought that they were just different terms for the same thing.
Offline
My understanding is that hybrid-sleep will save ram to disk on suspend, so that one can resume if battery depletes. On the other hand, suspend-then-hibernate will pro-actively hibernate after a set period of time, there-by preserving battery. So in other words, hybrid-sleep won't preserve battery at all.
That's my understanding anyways.
Offline
https://man.archlinux.org/man/systemd-s … ESCRIPTION
As I understand it, hybrid-sleep suspends to both RAM and disk at the same time (slower and RAM stays powered until battery is drained) and suspend-then-hibernate suspends to RAM first and then if you don't resume within a set time, a wake-up is triggered and then it suspends to disk (to get to a lower power state).
@bdombro: it doesn't seem like the suspend.service would be triggered by a call to `/usr/lib/systemd/systemd-sleep suspend-then-hibernate`. That part of the docs just says it will use those values to write to /sys/power/{disk,state}. And "suspend-then-hibernate" is not a valid value to write to the kernel interface; it is a higher-level concept implemented by systemd.
Last edited by Raynman (2022-01-05 21:29:36)
Offline
@raynman your symlink seems to work too <3
ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
Offline