You are not logged in.

#1 2024-08-24 12:22:33

Bootlace6
Member
Registered: 2024-08-24
Posts: 1

How to configure suspend-then-hibernate after dropping 5% battery.

Hello, I've set up hibernation successfully. Now I want to have systemd's suspend-then-hibernate power option to only hibernate the system after 5% of battery drop. I've read man systemd-sleep.conf, it explains that HibernateDelaySec= option is to determine how many minutes/hours you want the system to stay suspended, then hibernate. I was liking the way auto hibernation was working in Windows more, Windows would hibernate system only if 5% of battery drop happened. So if I left my laptop plugged into power and it has 100% battery, system would stay in suspend indefinetely as battery won't drop, until I plug out from power source, then if battery dropped to 95% Windows would sleep. That was a really good design but I couldn't find if this can be done with systemd's suspend-then-hibernate implementation, and looking for solutions if there's any.

Offline

#2 2024-08-30 00:17:47

mesaprotector
Member
Registered: 2024-03-03
Posts: 116

Re: How to configure suspend-then-hibernate after dropping 5% battery.

It's not clear - do you want the system to hibernate when there is 5% of battery left, or when the battery percentage has dropped 5% from where it started? The former is supposed to be the default behavior of suspend-then-hibernate.

The latter is not exactly possible with systemctl. If you know how quickly your laptop drains during sleep (it's not hard to test; just leave it sleeping for a few hours and calculate the rate the charge has decreased), then you can set HibernateDelaySec. This won't be enough if you're suspending the laptop while plugged in and then unplugging it. It'd be better to just avoid doing that, but if you really want to force it to work, you should have the laptop wake up if it detects a switch from AC to battery power, and then you can sleep it again.

Offline

Board footer

Powered by FluxBB