Ubuntu – What kind of battery management is preinstalled on a clean Ubuntu 18.04 install

batteryhibernatelaptoppower-management

A friend recently told me that it is important to not charge the laptop battery fully, so that it lives longer. I didn't know if that is true, and if it is I would expect the battery hardware or the OS to handle that without me fiddling with it.

To back this claim up, here's a quote from Lenovo's Vantage Tool on Windows:

If you primarily use your computer with the AC adapter attached and only infrequently use battery power, you can increase the lifespan of the battery by setting the maximum charge value to below 100%. This is useful because batteries that are used infrequently have a longer lifespan when they are maintained at less than a full charge.

I have a ThinkPad X1 Yoga with Ubuntu 18.04, but I expect the answer not to be strongly dependent on the laptop model and the Ubuntu version.

What kind of battery management is preinstalled on Ubuntu without further configuration?

I am thinking of things like the following:

  • stops charging at XX%
  • warns at low battery
  • hibernates on critical battery level

I am worried I might be destroying my battery's life by leaving the laptop constantly plugged in over a few weeks.

In the case that Ubuntu does not already have precautions set up, please also mention in your answer a suggestion regarding this.

Best Answer

NOTE: This answer had been edited majorly, introducing significant semantical changes:

Assumedly valid for both Ubuntu 18.04 and 20.04:

The default Gnome Settings app offers blanking the screen, switching off bluetooth and wifi to save battery power, and auto-suspending when idle, in the range from 15 mins to 2 hours.

GUI for advanced battery-management options:

I don't know where is the GUI for adjusting the below discussed settings. What I mean is, it might got nuked, which is a trend these years with the default Ubuntu experience (Gnome 3 desktop).

Where are the actual configs:

Battery-related settings now exist redundantly in the system, which is highly misleading.

With that said, they are probably in /etc/UPower/UPower.conf, as pointed out by @hackerb9 (thanks for the find, @lucidbrot)

Additionally, they are present among the system-wide application settings, accessed via the gsettings API, exposed by the optionally installable application, dconf-editor.

Those ones in gsettings are organized in the org.gnome.settings-daemon.plugins.power namespace, and apparently they do not take effect.

I take this from the above linked answer by @hackerb9, plus the telling comment section under this blog article.

(Actually, some settings in that gsettigs namespace keep taking effect, just not the ones that are introduced below.)

What can be configured:

There is a choice whether one wants to work in terms of battery level percentage or in terms of remaining time (gsettings default: time, UPower.conf default setting: percentage).

The following can be configured as both percentages and remaining time, both in UPower.conf and in gsettings, defaults being the same among them:

  • from where it is considered low (default: 10% or 1200secs)
  • from where it is considered critical (default: 3% or 300secs)
  • level at which an automatic action is taken (default: 2% or 120secs)

Critical battery action choices in UPower.conf:

hybridSleep | hibernate | shutdown (default: hybridSleep, with fallback to the other options)

Critical battery action choices in gsettings:

suspend | hibernate | shutdown | and other options (default: suspend)

Worth repeating, it's likely the ones in gsettings do not play a part any more.

Now for another thing to ponder over: the UPower.conf file starts with the following comment:

Only the system vendor should modify this file, ordinary users should not have to change anything.

Ubuntu Help on power/battery topic

(apparently for 20.10, in other words Gnome 3 (shared by 18.04)):

https://help.ubuntu.com/stable/ubuntu-help/power.html.en

Battery care via additional software:

This article commends TLP for 18.04 and higher.

TLP is well-discussed on this forum. It seems to have pretty fine-grained settings for when to start and when to stop charging, but these settings are vendor-specific (IBM/Lenovo ThinkPad, when additional dependencies are met).

Battery care via BIOS:

If you primarily use your computer with the AC adapter attached and only infrequently use battery power

In my Dell laptop's BIOS menu, there is a dedicated checkbox for exactly this use case. IIRC it's not being explained, how Dell will protect the battery, but the presence of this checkbox suggests that they are doing something differently then. So also take a good look around in your BIOS menu.

A relevant admission:

Perhaps I should have checked the aforementioned kept-on-charger BIOS checkbox, because that was my use case too. But I found it too late.

So, possibly - but not proven - due to this after 4 years, my battery has swollen to double its original thickness, and had to be removed. Due to this, right now I can't test or confirm any battery-related behaviour.