You are not logged in.

#1 2022-01-05 17:34:28

bdombro
Member
Registered: 2022-01-05
Posts: 6

always suspend-then-hibernate instead of suspend

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

#2 2022-01-05 17:51:46

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 4,867

Re: always suspend-then-hibernate instead of suspend

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


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2022-01-05 18:31:33

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 15,039

Re: always suspend-then-hibernate instead of suspend

You can also just properly configure this via standard configuration: https://wiki.archlinux.org/title/Power_ … on_request

Offline

#4 2022-01-05 19:17:31

bdombro
Member
Registered: 2022-01-05
Posts: 6

Re: always suspend-then-hibernate instead of suspend

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

#5 2022-01-05 20:27:01

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 4,867

Re: always suspend-then-hibernate instead of suspend

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.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2022-01-05 20:56:59

bdombro
Member
Registered: 2022-01-05
Posts: 6

Re: always suspend-then-hibernate instead of suspend

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

#7 2022-01-05 20:57:37

Raynman
Member
Registered: 2011-10-22
Posts: 1,359

Re: always suspend-then-hibernate instead of suspend

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

#8 2022-01-05 21:00:49

bdombro
Member
Registered: 2022-01-05
Posts: 6

Re: always suspend-then-hibernate instead of suspend

@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

#9 2022-01-05 21:01:51

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 4,867

Re: always suspend-then-hibernate instead of suspend

Raynman wrote:

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.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#10 2022-01-05 21:20:50

bdombro
Member
Registered: 2022-01-05
Posts: 6

Re: always suspend-then-hibernate instead of suspend

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

#11 2022-01-05 21:25:23

Raynman
Member
Registered: 2011-10-22
Posts: 1,359

Re: always suspend-then-hibernate instead of suspend

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

#12 2022-01-06 00:26:34

bdombro
Member
Registered: 2022-01-05
Posts: 6

Re: always suspend-then-hibernate instead of suspend

@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

Board footer

Powered by FluxBB