8

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.

2 Answers 2

10

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 ...

  1. Open dconf-editor: Find dconf-editor
  2. 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
    
  3. This will give you lots of options to control how Ubuntu responds to various power statuses: plugins-power
  4. Find percentage-critical and click the row
  5. 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: percentage-critical
  6. Save the change and go up a level
  7. Find "Use Time for Policy", which will be at the very bottom and toggle the option off: Use Time for Policy
  8. 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

  1. Still in dconf-editor, find "critical battery action"
  2. Toggle the default off
  3. Choose your poison: Critical Battery Action 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.

8
  • 1
    Minor issue: I can't find the gnome option. I feel silly for not mentioning it, I'm not running gnome....... I've got KUbuntu installed. So no gnome at all.....
    – J-Cake
    May 24, 2021 at 9:03
  • 4
    @JacobSchneider You can find these settings in System Settings/Hardware/Power Management/Advanced Settings in KDE.
    – danzel
    May 24, 2021 at 10:27
  • 1
    You, my friends, are heroes. Thanks so much for all your help. As for the point about data loss, most of the programs I use (mostly IntelliJ) have autosave functionality, and the other stuff is mostly in the browser, so I'm not too fussed about that.
    – J-Cake
    May 24, 2021 at 10:58
  • 2
    @JacobSchneider: even autosave might not save you from data loss or corruption if the battery dies. There are typically several levels of caching that can exist between "autosave" and "bits actually written to disk such that they can survive power loss". There also may be moments in which a file (or metadata!) is partially-written, at which time loss of power would lead to data corruption. Here there be dragons.
    – minnmass
    May 24, 2021 at 20:11
  • Hmm. Understood. What level of data loss are we talking about here? Is it whole-drive corruption, or just that one file? Can it stop the OS from booting correctly?
    – J-Cake
    May 25, 2021 at 8:05
0

Since the built-in battery indicator-controller software isn't working correctly log into Synaptic, install and try others until you find a battery monitor-controller that works correctly. Keep a list so you can uninstall the one(s) that doesn't work.

1
  • I'm not sure that's a software thing. Windows is showing the same symptoms, leaving me to conclude it's a hardware issue, but it may interest you to know that killing the upower service does nothing...
    – J-Cake
    May 27, 2021 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.