My T450s Thinkpad has two built-in batteries--one hot-swappable and one inside the laptop. Lenovo calls the former "external" and the latter "internal". When not plugged in, the external battery provides charge until it hits a 5% low water mark, at which point the laptop starts using the internal battery.

What I want: (1) to control from Debian Linux which battery the laptop draws power from at any given time while not plugged in, and (2) to set a value of my choice for the low water mark for the automatic switchover to the other battery, as I think 5% is too hard on LiIon cells. The current firmware from Lenovo is no help--I don't see any setting even remotely related to these problems.

  • 1
    The laptop can't distinguish between an external battery and an AC adapter. – Ignacio Vazquez-Abrams Mar 19 '18 at 23:44
  • 1
    @Ignacio yes, it can; the question isn’t about an external battery pretending to be an AC adapter to provide power, it concerns the two built-in batteries, one of which is swappable (yes, “external” is misleading). – Stephen Kitt Mar 20 '18 at 2:33
  • Did you consider the chance of it being an hardware feature, and thus not controllable by software? Because it looks like it. – Marco Bonelli Mar 20 '18 at 3:07
  • @StephenKitt edited to reflect the somewhat confusing names Lenovo uses for these batteries. – Stan Mar 20 '18 at 7:51
  • @MarcoBonelli that may well be--but packages with close and similar functionality like this one gave me higher hopes. – Stan Mar 20 '18 at 7:54

There is a module named tp_smapi.

For example, you can change the threshold like this:

echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
cat /sys/devices/platform/smapi/BAT0/*_charge_thresh

The link also contains a script which will allow you to select the battery to discharge firstly.

  • 2
    tp_smapi doesn’t work on the T450s. – Stephen Kitt Mar 20 '18 at 9:54

To answer you question number 2 you could define TLP battery tresholds, or, if you have kernel 4.17 or newer you can use an interface very similar to that provided by the old tp_smapi module. @davidbaumann's answer would look like:

echo 40 > /sys/class/power_supply/BAT0/charge_start_threshold
echo 70 > /sys/class/power_supply/BAT0/charge_stop_threshold
cat /sys/class/power_supply/BAT0/charge_*_treshold

Note that this would need root permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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