11

I would love for the lid closing behavior to "suspend" for a certain amount of time (1 or 2 hours) and then "hibernate" to save battery. Is there a way to change the settings of "suspend" so that it go into "hibernate" after some time?

Thank you!

1 Answer 1

16

To start using this function you need to create a file /etc/systemd/sleep.conf with the next content:

[Sleep]
HibernateDelaySec=3600

Then you can test it by command:

sudo systemctl suspend-then-hibernate

(you can edit HibernateDelaySec to reduce delay to hibernate). If all works fine you can change Lid Close Action, to do it you need to edit the file /etc/systemd/logind.conf

You need to find option HandleLidSwitch=, uncomment it and change to HandleLidSwitch=suspend-then-hibernate. Then you need to restart logind service(wirning! you user session will be restarted) by the next command:

systemctl restart systemd-logind.service

Thats all! Now you can use this nice function.

4
  • 1
    Really nice to prevent power drain while on the go, but if the laptop is connected to AC all night, and I open it after a few hours, what's the point of finding it hibernated? Is there a way to switch to suspend and poll the AC status every hour or so, and in case we're not connected to AC it hibernates? At least, macbooks behave like this, and actually makes sense.
    – sscarduzio
    Jan 12, 2020 at 11:44
  • 3
    @sscarduzio HandleLidSwitchExternalPower or HandleLidSwitchDocked - see man logind.conf.
    – knezi
    Apr 1, 2020 at 8:41
  • As of systemd version 252, this option has been updated to hibernate when the battery is low. github.com/systemd/systemd/issues/25269
    – Kishor V
    Dec 31, 2022 at 5:59
  • As of systemd version v253-rc2 this feature has been reverted to the original behavior (against the desires of a very narrowminded developer named bluca thank god)
    – Joe
    Feb 12 at 4:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .