How to set battery charging threshhold on EOS

I am having an issue in regard to battery charging on linux. when I bought my Lenovo laptop I was on windows so I installed a binary on my system that allowed me to set the battery charging into “Conservation mode” so that i only charges and uncharges to keep the battery charge in a certain range and othewise uses AC instead of battery. This settings persisted over when I switched to linux because I suppose it wrote it into BIOS /EFI . But now suddenly today it stopped to work for some reason, I did a little search and found maybe “tlp” can do the same thing, but when I try to install it it says there is a conflict and I am not sure If I want to remove that program as I don’t know what it does, Any suggestions on what to do? I suppose there should be a option If I can boot into BIOS, right? I also can attach the windows I have installed in a External HDD for this laptop which had Windows on it, boot into it, install that binary and set it up again and hope that the settings persist again.

here is the conflict I get when trying to install tlp:
resolving dependencies...
looking for conflicting packages...
:: tlp and power-profiles-daemon are in conflict. Remove power-profiles-daemon? [y/N] N
error: unresolvable package conflicts detected
error: failed to prepare transaction (conflicting dependencies)
:: tlp and power-profiles-daemon are in conflict

And trying to fix it using tlp gives me this:

 systemctl status tlp.service 
● tlp.service - TLP system startup/shutdown
     Loaded: loaded (/usr/lib/systemd/system/tlp.service; enabled; preset: disabled)
     Active: active (exited) since Wed 2023-04-12 09:12:06 +0330; 3h 33min ago
    Process: 767 ExecStart=/usr/bin/tlp init start (code=exited, status=0/SUCCESS)
   Main PID: 767 (code=exited, status=0/SUCCESS)
        CPU: 516ms

Apr 12 09:12:05 lenovo-i315 systemd[1]: Starting TLP system startup/shutdown...
Apr 12 09:12:06 lenovo-i315 tlp[767]: Applying power save settings...done.
Apr 12 09:12:06 lenovo-i315 tlp[767]: Error in configuration at STOP_CHARGE_THRESH_BAT0="60": conservation mode not specified or invalid (must be 0 or 1). Skipped.
Apr 12 09:12:06 lenovo-i315 tlp[767]: Setting battery charge thresholds...done.
Apr 12 09:12:06 lenovo-i315 systemd[1]: Finished TLP system startup/shutdown.

Charging threshold is for select systems - your firmware would have to provide support for it.

Lenovo is one of the few systems supporting this - I think there is a package in the repo - I just don’t recall it’s name - it is for thinkpad specifically. mention a package tpacpi-bat and for older TP’s tp_smapi and a list of Lenovo systems - tested and working

Most system doesn’t support such threshold and your only helper is a script which can watch your battery and notify when your desirec threshold is reached.

If you cannot get it to function - I create an allround script some time ago.

Save the script in /usr/local/bin/ (require elevated permission)

The easiest way of running the watch is to use a systemd service

Create the folder ~/.config/systemd/user

mkdir -p ~/.config/systemd/user

Create a service unit using your favorite editor

xdg-open ~/.config/systemd/user/charge-notify.service

Paste below content and save the file

Description=Charger notify service

ExecStartPre=/bin/sleep 30


Enable and start the service

systemctl --user enable --now charge-notify.service
1 Like

Thank you, it is very interesting to learn how to make a custom job for systemd, but for the issue I figured out that the description in config file was misleading and for non-ThinkPad Lenovos the value should set to “1” so that it enabled to default 60% value.