linrunner / TLP

TLP - Optimize Linux Laptop Battery Life
https://linrunner.de/tlp
GNU General Public License v2.0
2.51k stars 129 forks source link

Multiple Profiles (more than BAT/AC) #730

Closed kai-tub closed 3 months ago

kai-tub commented 4 months ago

Hey, first of all, thank you for the awesome project! :heart:

Is your feature request related to a problem? Please describe.

When I unplug my fully charged laptop, I would prefer to set the different power-saving features not as aggressively as I would whenever my charge goes below 50%.

I understand that I could set the profile to AC manually. Looking at the CPU_X related features, I would target something more like power_balance first on the battery and then switch to power when I am below a different battery threshold. Or I would like to manually choose between different BAT profiles to select the desired profile depending on why I am on BAT, like showing a graphical demo or writing some docs while on a long train ride.

Only having the AC and BAT profiles does not cover these use cases.

Describe the solution you'd like

Ideally, I would like support for multiple battery (maybe also AC ?) profiles. I would like to be able to switch between them manually (for example, be able to have a low-power mode when I am on the go and a normal mode when I am running around in the office) and also switch the profiles whenever the battery reaches a certain threshold.

But I don't think that it is necessary to have TLP automatically switch the profiles depending on the charge level in the beginning, as this could be managed by a Upower based dbus script or udev rule for laptops that trigger discharge events. This could be a follow-up feature.

I took a quick look at the architecture section, and it mentions that:

TLP’s actions are event-driven. There is no TLP daemon, instead TLP depends on standard system daemons to monitor the relevant events: [...]

So I am unsure if this multi-profile support makes any sense with TLP's design philosophy.

But here is how one could implement it: I am not suggesting XXX_BAT_PROFILE_N, but rather a list of config files only read if the current profile is selected. So one would have the default configuration under /etc/tlp.conf and then another file for each profile, like /etc/tlp_low_power, which is only read if the profile is selected (low_power). These settings would overwrite the ones from the default profile, allowing one to make minimal changes.

To trigger the change manually, I would call tlp bat <profile_name>.

This would have the following benefits:

A potential issue might be that it might have unintended consequences if I only set a BAT variable in the low-power profile and forget to set the AC variable in the tlp.conf, implying that this value might impact the AC behavior when plugging it back in.

I understand that this is relatively similar to power-profiles-daemon but as it is mentioned in the TLP PPD, TLP does quite a bit more, but switching between BAT and AC is a bit limiting.

Does the proposed multi-profile, multi-config approach sound feasible? I am happy to discuss this further. :)

Thanks!

linrunner commented 3 months ago

Hi,

it's not that your suggestion is new or that I haven't thought about it several times. In the end, however, the problem is always that a complete additional profile - in addition to AC and BAT - bloats the configuration and makes it more confusing.

This is even more true for your suggestion to introduce separate files for each profile. If only because all parameter names would have to be changed to those that do not contain a profile name. This would indeed break interfaces - namely to various tools based on TLP. Additional complexity would come from the need for backwards compatibility with old configurations.

I don't have the slightest desire to build all these case distinctions into the code, test them for every release, and include them in the documentation. By the way, no user would want to read that either.

Multiple profiles are a case for a GUI tool, not a "command-line with config files" tool.

TL;DR: You are grossly underestimating the effort. Take a much closer look at TLP's code before making such sweeping suggestions.