How to make laptop hibernate when lid closed and power is off?

I am using XFCE and in Settings Manager->Power Manager->Laptop Lid I have set the condition: When laptop lid is closed and On battery - to Hibernate.

However if the lid is closed and the power goes off the laptop stays on. The only way to hibernate it in this situation is to open the lid and close it again - then it hibernates.

I want to make it automatically hibernate when the power goes off (if the lid is closed) without the need of human intervention.

How do I do that?

Another problem I am facing actually is that currently after the lid close (with power off) the PC actually “does something” (which I don’t know if it is hibernation or shutdown) but after powering it on it starts the whole boot up process and I don’t know why.

This means system must briefly power on to perform hibernation. So far systemd upstream was reluctant to implement it, because if system powers on in your rucksack and fails to hibernate it can damage itself. I had such case once.

So your alternatives are

I am not sure if I understand why you say that. The current situation is:

  • the system is on
  • the lid is closed
  • the power goes off
  • the system stays on

So what is there to briefly power on?

Sorry, I misunderstood you, I assumed system is suspended on lid close.

One possibility is to add ACPI even handler for AC OFF event. See https://wiki.archlinux.org/index.php/Acpid for example. Whether Xfce power manager supports it I do not know; it is probably better asked on their forums.

Thank you, I will try with acpid. However there seems to be a bug. I remember when I used 12.2 on the same laptop, the hibernation worked exactly as I want it. Now I don’t even understand why the system boots as from initial startup when I press the power on button (after it has been hibernated manually).

Thanks again for sending me to acpid. I was able to create an event listener and suspend the system when power goes off if lid is closed.

However I can’t get pm-hibernate to work at all - the system doesn’t react to it at all. I tried the quirks too but without success.