I want to hibernate on low battery:
SUBSYSTEM=="power_supply", \ ATTR{status}=="Discharging", \ ATTR{capacity}=="[0-5]", \ RUN+="/usr/bin/systemctl hibernate", \ This works well if the system is awake. If suspended however, it doesn't hibernate until I wake it, then instead of allowing me to unlock it immediately hibernates.
How can I make this event either work while suspended, or trigger a wakeup (and then hibernate) itself, without me opening the lid?
I have tried adding:
ATTR{power/wakeup}="enabled" without success. Indeed there is no wakeup currently in /sys/class/power_supply/BAT1/power/ - actually though /sys/class/power_supply/BAT1/device/power/wakeup exists and is already enabled.
I gather I can't make the udev rule run while suspended, I need to trigger it to wake on low battery separately (then the udev rule can run and hibernate).
This seems already implemented in drivers/acpi/battery.c:
/* * Wakeup the system if battery is critical low * or lower than the alarm level */ if ((battery->state & ACPI_BATTERY_STATE_CRITICAL) || (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags) && (battery->capacity_now <= battery->alarm))) acpi_pm_wakeup_event(&battery->device->dev); But that has not worked for me, I don't know if 'critical low' is another textual capacity level, I've only seen as low as 'Low', but it was at the time lower than the /sys/class/power_supply/BAT1/alarm.
NB: I am aware of hybrid-sleep, but that is not what I want, firstly since I would like to conserve some battery; but also so that I can use suspend-then-hibernate such that it hibernates on either low battery or time delay.