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.
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
:Then write your desired charging thresholds (your own values) to the virtual files in
/sys/devices/platform/smapi
: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.
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.
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.I could set my threshold to 60% by setting
/sys/class/power_supply/BAT0/charge_control_end_threshold
to60
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.
In most laptops is the Embedded Controller the one responsible for that. I suggest you to study the
ec_sys
module.then
You will see differences when charging and when discharging. There are also more interesting things to do like:
etc.