31

If a laptop is powered on and connected to AC power, is there a way to issue a command that tells it not to charge the battery?

EDITED:
Perhaps charging of the battery may be stopped if there were a way to fool the system into thinking the battery is already at 100% charge.

4
  • 3
    It is possible -- I know that Lenovo computers are able to do that with Windows loaded. Not sure if there is a facility to do this with Ubuntu.
    – cprofitt
    Commented Nov 16, 2012 at 18:02
  • 1
    Can you explain why you would want to do this?
    – coteyr
    Commented Nov 16, 2012 at 18:43
  • I have a BIOS option to do so. Not what you want exactly, but have a look there.
    – Timo
    Commented Nov 16, 2012 at 23:23
  • 1
    @coteyr: This vaguely-related question of mine explains why it's not ideal to always keep your laptop charged at 100%. Commented Aug 28, 2015 at 2:43

5 Answers 5

10

On Thinkpad devices, you can control the start and stop of the battery charging in Ubuntu. Run these commands in your terminal to install tp-smapi:

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

Then write your desired charging thresholds (your own values) to the virtual files in /sys/devices/platform/smapi:

echo 10 | sudo tee /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 100 | sudo tee /sys/devices/platform/smapi/BAT0/stop_charge_thresh

In the above commands you can change the values 10 and 100 to any value. The first one will help you to choose at what level charging must start and the second value will let you choose at what level charging must stop.

2
  • This only seeps to work for older Thinkpads (see thinkwiki.org/wiki/Tp_smapi#Model-specific_status for supported devices). On my newer Thinkpad Yoga X1 G4 and can use the /sys/class/power_supply/BAT0/charge_control_end_threshold for that purpose (no kernel moduler required in my case).
    – jeanggi90
    Commented Oct 12, 2021 at 8:04
  • 1
    Does anybody know of a way to accomplish this on recent Dell laptops? Commented Aug 28, 2023 at 13:05
8

You can't disable charging using any known software interface from user space. As it is, the battery controls from /sys/class/power_supply/BAT0 are static and dynamic readings as returned from the ACPI _BIF, _BIX and _BST controls, these are read only.

There are no ACPI controls that allow you to disable battery charging and on all the common x86 mobile platforms I've ever worked on the battery controls are not exposed. Normally this data comes from a battery gas gauge and are read using bit-banging i2c usually by an embedded controller. So you realistically have very little chance of reverse engineering this and most won't allow battery charging disabling.

1
  • +1 for one of the most complicated answers I've read in awhile. I've decided to buy a smart plug and write a script to turn off power to laptop charger once a week until charge depletes to 20% or some threshold set by user. Commented Dec 31, 2019 at 0:14
7

I could set my threshold to 60% by setting /sys/class/power_supply/BAT0/charge_control_end_threshold to 60 as su. Ubuntu shows charging icon, but won't charge past 60%. The battery charging indicator LED also turned white, indicating that charging has stopped, much like it's behavior on Windows when Asus' "Battery Lifespan Mode" is activated. Also, the file resets to 100 on every boot, you might want to add a rule to set it to 60 on boot.

Source. I didn't have enough reputation to comment this, so I answered it with my own experience. Do note that most of the people that used this method had Asus laptops and Asus has a similar functionality on Windows by default. I highly doubt if that should make a difference, but one user with an Ideapad said they couldn't find the file. ThinkPad owners should try using TLP's setting for battery threshold.

EDIT: Heads up, this seems to be a very dirty method, has rendered my machine unbootable in certain situations. And this took me a lot of tries to figure it out because it seemed to be working at certain times and unbootable after sleep.

EDIT 2: Seems like this solution is actually documented well on Arch Wiki. In fact, they've provided workarounds for the issue I quoted in my edit, Please refer to the section Persist after hibernation where it provides workarounds for the black screen after sleep issue.

3

This is highly dependent on hardware. Most laptops at the hardware level, will not allow you to stop charging the battery. LION batteries actually benefit from a small uncharge - recharge cycle, and most laptops will have that cycle built in at the hardware level.

Meaning as your battery indicator says 100% the battery is actually discharging and recharging a tiny little bit to keep it healthy. Also, for most laptops 100% is not full.

Some laptops in windows, have an option to "Disable charging", but this was just a throwback to NiCad batteries. These days all that "setting" does is enable "performance" mode.

If your looking for the same kind of switch then I recommend Jupiter. It will allow you to easily move between performance modes, but again not control charging directly.

Because stopping that charging cycle is very bad for current batteries it's not very popular. Because it's not popular, I doubt you will find a good GUI tool to do it. Your best bet, might be looking around in /sys/class/power_supply/BAT0 like areas and seeing what you can find, but I am pretty sure, that your not going to be able to disable charging.

3

In most laptops is the Embedded Controller the one responsible for that. I suggest you to study the ec_sys module.

modprobe ec_sys

then

hexdump -C /sys/kernel/debug/ec/ec0/io

You will see differences when charging and when discharging. There are also more interesting things to do like:

  1. use AC power (if connected)
  2. use battery (even if AC is connected)
  3. charge/discharge

etc.

1
  • 1
    You can also find a detailed Embedded controller map in DSDT acpi table.
    – Zibri
    Commented Jan 6, 2018 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .