Saving Ubuntu Laptop Battery Life

haRies Efrika
5 min readOct 20, 2021

Simple tweak to prolong your laptop battery life.

And by extending battery life, I don’t mean that you can use your laptop in battery mode longer than it used to be, no no. Imagine that when you newly purchased laptop, it could last for 8 hours — then 5 years later, it can still run like 7 hours on battery. Interesting, yes?

I have been changing laptops given by the companies I have been working with. Let’s take example of last 2 laptops I had. The first one lasted for 2 years before the battery got swollen (“pregnant” 😆 ). I used to charge it until 100% then plug off the charger, and when the capacity is low like 10%, then I would recharge it back. The IT support who saw it advised me to always plug in the charger, it should prolong the battery life, he said. Then of course I took that advise for my 2nd laptop.

The result? It did not get swollen for sure, but the capacity dropped a lot, like it could only lasts for half hour on battery, within only a year from new!

I had a discussion with my friend, he mentioned his Windows laptop is still perfect in regards to battery capacity after several years. I am wondering is it true because I have been using Linux (Ubuntu) and it does not have good battery and charging management? Makes sense. Then I did my homework, dig up some readings, did some tests and came to this conclusion.

The battery cells degrade every time it charges and discharge

So if you charge the battery until 100% then use it until it drops to 10%, then charge it back fully, the age will be short. We need to keep the charge and discharge shallow.

Q: Could you explain more about terms: charge, discharge and idle ?

  • Charging means the electric current flows into battery (topping up the energy) as well powers up the laptop.
  • Discharging means the laptop provides energy by itself without help from AC power.
  • Idle means the laptop is supplied by AC power supply only, and has no connection from the battery.

Q: So during what capacity I should charge my laptop and when I should plug it off ?

If you do mobile a lot, traveling from one meeting rooms to another, and relies on battery a lot, you should recharge the battery until 80% (AND NO MORE), then when it drops to 40% (AND NO LESS), you need to plug in the AC adapter back.

If you treat your laptop as desktop, almost all day sitting on table relying on AC power — then you should charge the battery no more than 50%, and recharge back when it goes down below 45%. Wait a minute — WHAT ??

Q: It is so troublesome to always plug in/ out battery charger like that, especially in the middle of work. Do we have another solution?

Sure, let it be handled by the operating system. Each manufacturer especially on new laptops have their own ways and software to manage the charging thresholds.

Start threshold : below this percentage capacity, the battery will be charged.

Stop threshold : when it reaches this percentage capacity, the battery will stop charging and enters IDLE mode.

These two parameters, should be customized in newer laptop models. My new laptop is Lenovo Thinkpad Carbon X1, and we will be using it as examples in this article.

Q: Can we control the thresholds with Ubuntu OS Fossa 20.04 ?

Yes we can. We only need to install this utility: TLP

sudo add-apt-repository ppa:linrunner/tlp
sudo apt update
sudo apt install tlp

Then we set the threshold using this command:

sudo tlp setcharge 45 50 BAT0

The above command will set the start threshold to 45% (means if battery capacity is ≤ 45% it will start charging), and will set the stop threshold to 50% (means if battery capacity reaches 50% it will stop charging and change to IDLE).

In above figure we can see that battery status is discharging, means the power comes from battery, and it is currently 46.1%. Then let’s see what happens if we plug in the AC charger:

The status becomes IDLE. (Why idle, because it is still above start threshold). The AC charger does not flow any current to the battery, it is just like you are not using battery at all. Very ideal for desktop setup!

Q: Will the battery percentage go up or down in Idle status ?

It will eventually go lower, but will take long time like probably some hours or even days before the tlp-stat -b will give you reduced value of battery percentage. And later after long while when battery is below 45% the electric current will charge the battery and stops at 50% and be back idle again.

On the other hand, if you do not use charging threshold control like this, then you will charge the battery until full 100% and if it goes to 99% it will charge back and so on. This makes the battery runs hot and decreases battery life.

Setting up the thresholds narrow to 45–50% as advised from the referenced article will minimize the physical damage over time. Main source will be taken from AC power, the battery is like not used at all, and getting 5% down will take a long while — you slow down the charging cycle count!

Q: If I shutdown the laptop, should I keep the charger plugged in ?

No, you should plug it out, because the OS will no longer control the charging threshold and it will top up to 100%.

— — —

Thanks for reading, cheers 🍻 !