ThinkPad battery charge thresholds

If you want to take good care of your lithium-based battery, you should not charge or discharge it completely, but stick just to a part of the total range. This way you can increase the number of charge-discharge cycles it survives and thus prolong it’s life.

Certain laptops offer ways to set battery charging thresholds.

So, I have a X230 and I would like to conveniently (Plasma widget?) see if thresholds are active and have the possibility to easily change them.

With standard power management software likje UPower this is not possible, since it doesn’t even know about thresholds and developers don’t seem to be overly concerned about this.

https://bugs.freedesktop.org/show_bug.cgi?id=90975

https://github.com/evgeni/tp_smapi/issues/17

One of the ways to configure thresholds is to use TLP. With it you can set charge-start and charge-stop levels using special kernel module acpi_call (or tp_smapi for older models).

However, TLP is a simple command line tool. Configuration can be set using commands or by configuration file. To interact with TLP even just to read configuration you need root access. There is also python/GTK user interface (tlpui), but it also needs to be run with root privileges (using gksu internally). That is not exactly ideal approach and probably won’t work on Wayland.

So what would be the right way to do this? If we take UPower as an example, we should have a core process running as root, exposing it’s interface on D-Bus system bus. This interface can then be controlled by unprivileded user programs in a convenient way.

I am currently working on implementing this solution – “Threshy”. The source code is on my GitLab repository Threshy along with simple GUI Threshy-GUI. Both should be available also on AUR as soon as they are ready.

Next up: how to write D-Bus system bus daemon in Qt.

Leave a Reply

Your email address will not be published. Required fields are marked *