Comment 11 for bug 1852911

Revision history for this message
Andrea Gadotti (aerdna-itto) wrote (last edit ):

I have found a (dirty?) workaround for this. The idea is simple: use a udev rule to suspend the laptop before UPower shuts it down. This can be done by creating a file /etc/udev/rules.d/99-lowbat.rules with the following content:

# Suspend the system when battery level drops to 5% or lower
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl suspend"

You can of course tune the threshold.

This method seems to work well for me. If you want to use a threshold that's lower than the UPower one, *I think* you could set the PercentageAction parameter to 0% or 1% in /etc/UPower/UPower.conf, although I'm not 100% sure this is a good idea (the disclaimer at the beginning of the file seems to discourage users from directly modifying the file).

Reference: https://wiki.archlinux.org/title/laptop#Hibernate_on_low_battery_level

On a side note, I definitely wish this bug could be addressed. It's not normal that a computer just shuts down and makes you lose your work when there's still battery. Also note that afaik there's currently no way to enable hibernation with full disk encryption, so this limitation of UPower will become increasingly serious as more and more users will make the (right) choice to use FDE.