system76 / firmware-open

System76 Open Firmware
Other
962 stars 84 forks source link

Wake-up from suspend / sleep using an ACPI battery alarm #408

Open fhackenberger opened 1 year ago

fhackenberger commented 1 year ago

I'd like my system to resume from suspend on low battery to hibernate it automatically. There's the /sys/class/power_supply/BAT0/alarm interface which I'm trying to use. But my system doesn't not wake up again. I found two references that confirm the value in .../BAT0/alarm should be the same unit as .../BAT0/charge_now: stackoverflow, reddit.

Steps to reproduce

Disconnect the laptop from the power supply. Run:

echo $((`cat /sys/class/power_supply/BAT0/charge_now` - 1000)) | sudo tee /sys/class/power_supply/BAT0/alarm; sudo systemctl suspend; cat /sys/class/power_supply/BAT0/charge_now

and wait for a few minutes. My Lemur Pro 9 does not wake up automatically. If I wake it up manually, I can see that the charge_now after resume is below the alarm threshold. I also tried different offsets between 500 - 5000.

Expected behavior

The laptop should wake-up automatically as soon as the battery charge drops below the alarm level.

Actual behavior

The laptop remains suspended.

curiousercreative commented 1 year ago

Perhaps our EC does not support this feature?