linrunner / TLP

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

There should exist a user-defined config that takes precedence over /etc/tlp.conf #680

Closed andreihh closed 1 year ago

andreihh commented 1 year ago

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

No.

Describe the solution you'd like

I would like TLP to read a user-defined config that has priority over default configs (/etc/tlp.conf). For example, it would be amazing if I could set up a ~/.tlp.conf, which I could then persist as part of my dotfiles repository. Or if, specifically, /etc/tlp.d/.tlp.conf would take precedence over /etc/tlp.conf, even though other configs under /etc/tlp.d/ would not.

Describe alternatives you've considered

There was a similar request in https://github.com/linrunner/TLP/issues/579, but I understand the reason why it was dropped.

I could also persist the entire /etc/tlp.conf in my dotfiles repository.

Right now, I have a script that does in-place replacements for specific settings in /etc/tlp.conf using sed. EDIT: I set up a ~/.tlp.conf file and updated the script to append that to /etc/tlp.conf, seems a little bit cleaner than before.

Additional context

The current behavior in which /etc/tlp.conf takes precedence over user-defined customizations in /etc/tlp.d/*.conf is not ideal. I would like to persist my customizations in a dotfiles repository to make it easy to port them to a new device (which may have a newer version of TLP), and these customizations should take precedence .

I would prefer to not persist the entire /etc/tlp.conf in my dotfiles repository, because it contains a lot of clutter that's irrelevant for me, and moreover, if there would be new settings, or new documentation, or a default setting changed in a later TLP version, my dotfiles would overwrite them without me even noticing!

I feel my current approach of doing in-place replacements of settings in a setup script is the most portable and future-proof, but I think configs really shouldn't live in scripts...

Question

Does TLP follow symlinks when reading configs (e.g., /etc/tlp.conf and /etc/tlp.d/*.conf)?

andreihh commented 1 year ago

Ok, I will close this, I realized there was a misunderstanding on my side.

I had an older version of TLP that used /etc/default/tlp, which had some settings enabled / active by default. I had the impression that the newer versions just changed the config location to /etc/tlp.conf, but that's not the case.

Per the documentation in the new config, the default /etc/tlp.conf will always have all options disabled and will rely on intrinsic defaults (and I hope this commitment will be kept in future versions). I also checked, and symlinks are followed.

This means I can create a symlink in /etc/tlp.d/ to my config for device-agnostic settings that should be persisted as part of my dotfiles repository. I can make changes to /etc/tlp.conf for device-specific options that shouldn't be persisted in the dotfiles repository. The ordering is exactly what I need.