How can I get Linux to mimic Windows 11 on low battery power conditions?

On Windows if the system is low on power i.e 5% the system will automatically hibernate regardless of whether the system is sleeping or actively being used and also regardless of whether the lid is open or closed. This means that all unsaved work is safe and not vanished into thin air.
However, on Linux that would never happen and the battery level will reach 0% and simply die. The closest that you can get on Linux is with UPower, but it only works when the system is actively being used and not sleeping. Ultimately this has prevented me from switching to Linux on my Framework laptop for a very long time as I didn’t want my work to disappear if e.g I put my laptop in my bag and forgot to power it off and left it sleeping over a couple of days.

I wanted to know if there’s a way in which I can get Linux on my Framework 13 to mimic the low power behavior on Windows where it will automatically hibernates the system on low power regardless of whether the lid is closed or open and also regardless of whether it’s sleeping or actively being used?
I plan on using either Debian or Fedora.

KDE plasma does exhibit the same behavior by default: when you hit 10%, you get a notification warning you that you battery level is low, and when 5% is hit, the system will hibernate within 60 seconds if you do not act on it and hit the ‘Cancel’ button on the notification. Gnome 46 goes in suspend mode 15 minutes after you last left your laptop unattended by default, 10 minutes after the screen locks. You can change that.

Keep in mind different distros ship different versions of packages, for example debian will have old versions of these desktops that I would not recommend to use today but that’s up to you. Fedora is on the opposite side, with too fresh versions, I would avoid KDE 6 until they ship KDE 6.1.2 which is supposed to have a lot of fixes as it is very buggy for me right now to the point that I switched to gnome as a long time KDE user.

Gnome settings screenshots: search for “power”

Screenshot from 2024-06-28 19-14-10
Screenshot from 2024-06-28 19-14-17

What you want is called Hybrid suspend (aka hybrid sleep) Power management/Suspend and hibernate - ArchWiki

A hybrid of suspending and hibernating, sometimes called suspend to both. Saves the machine’s state into swap space, but does not power off the machine. Instead, it invokes the default suspend. Therefore, if the battery is not depleted, the system can resume instantly. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine’s state has not been lost.

But hibernate is not available by default on all distros, you need to look into how to enable it on your distro.

Can confirm that fedora does this form of hybrid suspend (at least on Gnome but I don’t believe it’s desktop specific).