Prevent OS from shutting down on low battery
I know, when the battery is flat, the computer dies. That's not the question. My question revolves around the fact that the battery meter in my computer gives inaccurate readings. The battery in my laptop lasts about 3 hours, give or take. But using my computer on battery will leave me about 25 minutes of usage. I have found an option in KDE that lets me disable automatic sleep and screen locking, although this only helps when the computer is connected to AC, then enabled, then disconnected, which really defeats the purpose in my mind.
The annoyance comes from Windows not having a problem with my battery at all. Ubuntu will run out of juice and not boot at all, but when booting to windows I get the whole list of battery warnings and indicators, but I can still use the OS until the battery truly dies. Even after Ubuntu runs out.
So I'm guessing (in true Linux spirit) there's a config file somewhere that keeps the OS from shutting down when it thinks the battery is at 0%. I just can't find it.
I've tried time and time again to reset or calibrate the meter, but that hasn't worked. I've even replaced the battery entirely.
Any pointers would be much appreciated.
Solution 1:
If you don't mind living on the wild side, you can tell Ubuntu to ignore everything and soldier on until the battery literally cannot supply enough juice to keep the lights on. This may have unintended consequences, such as data loss, though. That said, here are two options that you have available:
Option 1 — Lower Your Percentages
You can lower the percentages for when Ubuntu takes an action. The easiest way to do this would be with dconf-editor
, as it's visual and saves you from a bunch of copy/paste into a Terminal ... so long as you have the application installed.
If you don't:
sudo apt update
sudo apt install dconf-editor
Then ...
- Open
dconf-editor
: - Press Ctrl+F (or click the magnifying glass) to bring up the search option, then type "power". You are looking for:
/org/gnome/settings-daemon/plugins/power
- This will give you lots of options to control how Ubuntu responds to various power statuses:
- Find
percentage-critical
and click the row - Toggle the "default value" off and set the "custom value" to any number between the minimum and maximum range ... though the daemon will only respond to values between 0 and 100:
- Save the change and go up a level
- Find "Use Time for Policy", which will be at the very bottom and toggle the option off:
- Save your changes. This will ensure that — in the event the time remaining value is triggered before the percentage — that the system will not prematurely respond to a low battery
For most situations, this should be enough. However, if your battery "lies" about how much power it has remaining, then there's an additional step you can do.
Warning: Doing this can result in data corruption if a write is interrupted by a complete loss of power. I offer no warranty, implied or otherwise, on this action.
Option 2 — Tell the Machine to Stay Awake
- Still in
dconf-editor
, find "critical battery action" - Toggle the default off
- Choose your poison:
If you choose
nothing
, the machine will stay on until the battery is unable to provide enough voltage to the system. This will result in a very ungraceful shutdown.
Hopefully one (or both) of these options will give you some additional runtime.