You are not logged in.

#1 2023-01-21 09:18:51

hully
Member
Registered: 2022-11-14
Posts: 150

Gentler shutdown when battery is running out

My laptop was running on battery, and I realized it but forgot to plug it in.

When the battery reached 0%, it turned off. By turned off I mean it was playing sound, and the next microsecond everything was blank. Like it was abruptly disconnected from power.

This is no good to save work before turning off.

So I would like to implement a system that calls `shutdown` when the battery is 2% or lower.

What is the best way to do that?

Last edited by hully (2023-01-21 09:19:09)

Offline

#2 2023-01-21 11:45:46

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: Gentler shutdown when battery is running out

Offline

#3 2023-01-21 15:26:58

hully
Member
Registered: 2022-11-14
Posts: 150

Re: Gentler shutdown when battery is running out

Offline

#4 2023-01-21 17:02:02

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: Gentler shutdown when battery is running out

Would a notification not be more useful? That way you would have time to save your work.

Offline

#5 2023-01-22 02:00:55

hully
Member
Registered: 2022-11-14
Posts: 150

Re: Gentler shutdown when battery is running out

Head_on_a_Stick wrote:

Would a notification not be more useful? That way you would have time to save your work.

I will add the notification. That seems a good idea.

But I will keep the shutdown. What if the laptop is e.g. in a backpack ? Or simply I'm not in front of it?

Offline

#6 2023-01-22 08:17:22

seth
Member
Registered: 2012-09-03
Posts: 51,233

Re: Gentler shutdown when battery is running out

Go to S3/S4 early enough™ (S3 will still use battery, but slowly. S4 won't, once it's reached)

Online

#7 2023-01-22 09:21:13

hully
Member
Registered: 2022-11-14
Posts: 150

Re: Gentler shutdown when battery is running out

seth wrote:

Go to S3/S4 early enough™ (S3 will still use battery, but slowly. S4 won't, once it's reached)

I did not understand.

What does it mean to go to S3 and S4? When I should go to S3 or S4?

Anyway it seems to work.

The "problem" is that my laptop doesn't seem to boot if the battery level is below a certain threshold.

Is that possible? How can I find this threshold?

Offline

#8 2023-01-22 09:26:52

seth
Member
Registered: 2012-09-03
Posts: 51,233

Re: Gentler shutdown when battery is running out

What does it mean to go to S3 and S4? When I should go to S3 or S4?

https://en.wikipedia.org/wiki/ACPI#Power_states
"suspend to ram", "suspend to disk" and, as mentioned, "early enough"
For S3 this depends on the capacity of your battery and the power drain of the S3 state and teh frequency at which you expect to be able to deal with the situation.

Is that possible? How can I find this threshold?

Yes and vendor manual, but it's not a problem: you need to plug the AC no matter what.
Even if your hibernate the system right above that threshold, do you intend to then wake it on the same critical battery level?

Online

#9 2023-01-23 02:56:45

hully
Member
Registered: 2022-11-14
Posts: 150

Re: Gentler shutdown when battery is running out

I see. I implemented it. Thank you very much!

Offline

Board footer

Powered by FluxBB