I just learned that some Lenovo laptops include a utility that offers to limit battery charging capacity to within 0–80% in order to slow the attenuation of the battery lifespan:

screenshot

How can I do this in Ubuntu?

  • Can you confirm that aquaherd's answer works for you? – cfi Oct 27 '11 at 8:29
up vote 72 down vote accepted
+50

The charging thresholds are, very unfortunately, firmware and vendor specific.

The Lenovo ThinkPad user is luckily provided with a solution outlined on ThinkWiki.

It basically says that you would have to install and load the tp_smapi kernel module:

sudo apt-get install tp-smapi-dkms
sudo modprobe tp_smapi

and write the desired charging thresholds to virtual files in /sys/devices/platform/smapi:

echo 40 | sudo tee /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 | sudo tee /sys/devices/platform/smapi/BAT0/stop_charge_thresh

Then it will stop charging once it reached 80% and only start charging when it drops below 40%.

Toshiba and others might have a similar kernel module that exposes firmware functionality to the /sys or /proc space, but it is very unlikely for patent issues. For the same reasons, an application that could handle this would be either Thinkpad- specific or only address a few select vendors.

  • 1
    Thanks for this info. It's a good start - hopefully at least for the original Q asker. Hardware vendors should offer more support for linux driver developers. It's a shame that so much time has to be wasted having to reverse engineer hardware protocols. – cfi Oct 27 '11 at 8:32
  • 1
    I did in Ubuntu sudo apt-get install tp-smapi-dkms. It installed. Then I'm doing echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh and it says bash: /sys/devices/platform/smapi/BAT0/start_charge_thresh: No such file or directory. Why? – Alex Malex Dec 18 '12 at 9:07
  • 4
    @ændrük, alex@ubuntu:~$ sudo modprobe tp_smapi FATAL: Error inserting tp_smapi (/lib/modules/3.5.0-17-generic/updates/dkms/tp_smapi.ko): No such device. Did I miss something? I'm going to open a new question if I don't get the anwer. – Alex Malex Dec 23 '12 at 7:12
  • 1
    @Mika It seems that T420 needs an additonal acpi-call-dkms package as per linrunner.de/en/tlp/docs/… – mystrdat Jun 15 '16 at 14:07
  • 2
    It needs a ThinkPad laptop to set these charging values with TLP. TLP supports other laptops too (e.g. Dell, HP) but does not support all features as written in FAQ on the page from linrunner. For configuration of the charging thresholds see: linrunner.de/en/tlp/docs/… – Luckyrings Jun 14 '17 at 10:54

The accepted answer does not work on my new Lenovo T440s. Apparently the firmware changed. Following http://www.thinkwiki.org/wiki/Tpacpi-bat, I did

git clone https://github.com/teleshoes/tpacpi-bat.git
cd tpacpi-bat/
./install.pl
sudo ./tpacpi-bat -s ST 1 15 # load internal battery when below 15%
sudo ./tpacpi-bat -s SP 1 95 # stop charging at 95%
sudo ./tpacpi-bat -g ST 2 # when is external battery loaded?

For reference, I did this on debian testing but I'm sure it works in ubuntu just as well.

There's a somewhat nicer application now available to Ubuntu (and other distributions):

TLP – Linux Advanced Power Management

TLP brings you the benefits of advanced power management for Linux without the need to understand every technical detail. TLP comes with a default configuration already optimized for battery life, so you may just install and forget it. Nevertheless TLP is highly customizable to fulfil your specific requirements.

One of the parameters it controls is maintaining battery charging limits. It still works only for Thinkpads, but given the nature of the project—if the appropriate drivers for other devices will become available, it is likely these will get integrated into this project too. So if you're reading this comment in few years, check the documentation, maybe your device is actually supported.

Ubuntu packages are available in the official repository.

  • where is the list of supported devices? I am unable find a section on their doc. By any chance do you know whether tlp is supported for Thinkpad X1 carbon as well – Kasun Siyambalapitiya Apr 6 at 6:57
  • @KasunSiyambalapitiya, as of now, tlp is only a frontend to the two tools it uses for this purpose, Tp smapi and tpacpi-bat. As long as your model is supported by at least one of them, it should work (or file a bug). Yours doesn't seem to be listed on either of their supported hardware pages, but a quick googling reveals that the latter might work. – liori Apr 6 at 19:22

On my Toshiba R830 running Windows 8.1, I installed the Toshiba Power Saver application in order to limit the battery charge to 80%

When I boot on Linux (Ubuntu, Mint, etc), the maximum charge is still limited to 80%.

Therefore, the Toshiba Power Saver seems to store its configuration into the bios.

The only drawback is that if I want to travel with a fully charged battery, I have to reboot on Windows and change the Power Saver configuration.

  • 1
    welcome to askubuntu! Your results with Mint don't appear to be Ubuntu related. Can you rephrase your answer in terms that are relevant to this site? Thank you! – Elder Geek Jun 21 '14 at 13:49
  • 9
    Hello Elder Geek, this is bios related therefore will work with any operating system in a dual boot configuration. This Toshiba bios configuration is not accessible by bios menu but only with the Power Saver Application that runs on Windows only. – eosphere Sep 16 '14 at 21:03
  • 2
    Same for me on linovo yoga 3 11inch. – ctrl-alt-delor Aug 22 '15 at 18:19
  • 1
    Results with Mint are obviously Ubuntu-related. – Stefan Reich May 16 at 10:45

Did you check to see whether there is a BIOS setting on your laptop for this? My laptop had a Windows Application as well as a "Battery Life Extender" setting in the BIOS for this exact feature.

  • 3
    There is no such setting in the BIOS setup screen. – ændrük Jun 2 '11 at 15:55

Very often (almost always) this is an option in the BIOS that Windows can change remotely. It's very difficult to remote change this in Linux. My suggestion? When starting up your computer, smash the function keys, specifically F1, F2, F3, F6, F8, F10, and F12. One of these (maybe another) will put you into the bios menu. It says which key on startup, but it doesn't usually stay up long enough.

Look for power settings (only arrow keys here, no mouse). Find batter saver or batter optimizer or something along those lines. Change that to enabled, and then save and restart. This should do it.

Linux tends to freak out when the battery doesn't charge past 80%, but it will just ruin your expected charge times. Nothing to worry about here.

Still need help? Comment your question! Did I help? +1 me :)

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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