Linux – When using an external battery, do not charge on board battery just use running supply

batterylinuxpower-managementthinkpad

I have an external 21700 battery bank which provides usb-power for my laptop. It provides enough watts for my laptop to charge its onboard batteries while providing the running power. This is rather silly: if I'm using the external battery then I intend to deplete it fully, so it seems inefficient to charge an onboard battery depleting the external one faster just to then deplete the onboard battery. This battery-charging-battery costs energy and charge cycles of both units.

Is there a way to tell my computer NOT to pull voltage to charge the system, but just to use that for running power?

Note: I'm using a 8th gen X1 Carbon (relatively new) with 10th gen Intel tech.

Best Answer

For this model, you want acpi_call, then use the option to define charge thresholds.

Basically the idea would be to set the maximum percentage to which the battery should be charged to the current charging level once you plug in the external power bank, e.g. 43%

 cat 43 > /sys/class/power_supply/BAT0/charge_stop_threshold

Calculate the current battery level with the values in these two files:

/sys/class/power_supply/BAT0/energy_now
/sys/class/power_supply/BAT0/energy_full

Then it is a matter of activating and the threshold and removing it with a little script triggered by the plug-in/-out events. This udev-rule would do.

Related Question