Skip to content

Conversation

@dingbat32
Copy link

Adds the CHARGE_MODE setting that can be set to different options depending on your system.

On my Lenovo Legion, I can set it to Long_Life in order to limit the battery to 80% maximum charge. This uses the new charge_types property of the sysfs power supply class. This is equivalent to the old conservation_mode property, but has support for other hardware as well, such as with Dell or HP, although options may be different.

Not sure if I did everything correctly, but I think this a useful setting that I would like to see in TLP. I ran make checkall to check for any code issues, and did some testing on my system.

Will try and set the charge type for all batteries detected

Signed-off-by: Sven Willett <sven.willett@gmail.com>
Signed-off-by: Sven Willett <sven.willett@gmail.com>
@linrunner
Copy link
Owner

linrunner commented Dec 30, 2025

@dingbat32 Thank you for your PR.

You suggest implementing this as a generic feature without taking the actual underlying hardware into account. With your PR, the user would first have to check whether their hardware works with it and which values to use. But how can they find that out?

The principles for TLP's battery care are different. Hardware dependencies and properties are encapsulated in plugins, tlp-stat -b shows the user which battery features the hardware supports and the associated value ranges. Finally tlp setcharge validates the parameters. For a Lenovo (non-Thinkpad), for example, it looks like [1].

but has support for other hardware as well, such as with Dell or HP, although options may be different.

Yes, but unfortunately it's anything but uniform. The new "someday-maybe-standard" currently only exists for Lenovo (non-ThinkPads) [2] and Samsung (older models, not Galaxy Books) [3]. With Dell hardware, you write “Custom” and can then use charge_control_start/end_threshold in the conventional manner. For HP, however, there is nothing of the sort, as there is no kernel driver for it.

However, with charge_control_start/end_threshold, there are different value for every vendor/brand, which are not shown to the user in sysfs. I have documented therm all in [1] and the corresponding pliugins enforce them.

My suggestion: you integrate charge_types into the Lenovo plugin [4] as a case distinction. You have the hardware and can test it right away. Make sure to remain backward compatible, because not everyone has kernel 6.17 yet. For internal differentiation, the return value of _natacpi could be used, for example: 1=conservation_mode, 0=charge_types.

Please base further PRs on my current battery care development branch bat.d/tlp.stat as long as I haven't merged it to main.

[1] https://linrunner.de/tlp/settings/bc-vendors.html#lenovo-non-thinkpad-series
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86?id=da8f2708f9b69707f4efeb432a18395e46b4666f
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86?id=de2884c6cdd3d133704ce37393590dd1c761500c
[4] https://github.com/linrunner/TLP/blob/bat.d/tlp-stat/bat.d/15-lenovo

@linrunner
Copy link
Owner

ps. there is also #831 on this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants