Config to hibernate when battery is critically low

I want to make my laptop hibernate when battery is critically low but can’t find the config for that.

1 Like

Maybe you could do the equivalent of this: Laptop - ArchWiki

The stockholm repository has something similar to what you are looking for, it is a module which provides the means to trigger actions for different power levels (e.g. between 25% and 15% or below 15%): Sign in · GitLab

This is how i use the module for my laptop:

If you do not want the full-fledge version then you can probably copy-paste the relevant parts into your config

Funny, just an hour ago I added code for that to my config.

But if your battery sends discharging events, you probably want a udev rule (as described in the arch wiki).

1 Like

Great to learn about these. Thank you all.

1 Like

To other people just finding this now on Google, you can edit upower settings in Nixos like this

services.upower.criticalPowerAction = "Hibernate";
2 Likes