[go: up one dir, main page]

DEV Community

Mehdi mFat
Mehdi mFat

Posted on

How to enable battery charge limit on Linux

Some laptops allow you to set a limit on the battery charge level. This feature is known as a charge threshold. For instance, you can choose to stop charging the battery when it reaches 60%, which may help to prolong the battery's lifespan.

On my Lenovo Thinkbook 14s Yoga it's very easy to do this. Here are the steps:



sudo dnf install tlp tlp-rdw



Enter fullscreen mode Exit fullscreen mode


sudo nano /etc/tlp.conf



Enter fullscreen mode Exit fullscreen mode

add this line to the file:



STOP_CHARGE_THRESH_BAT0=1



Enter fullscreen mode Exit fullscreen mode

save and close.



sudo systemctl enable tlp.service
sudo systemctl start tlp.service



Enter fullscreen mode Exit fullscreen mode

Done! Now your laptop should stop charging the battery beyond 60%.


As you can see in the screenshot, the battery is charged until it reaches 59% and then stops charging above that limit.

To check if your laptop supports this feature run:
sudo tlp-stat -b

On my laptop the output is this:



$sudo tlp-stat -b
--- TLP 1.5.0 --------------------------------------------

+++ Battery Care
Plugin: lenovo
Supported features: charge threshold
Driver usage:
* vendor (ideapad_laptop) = active (charge threshold)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0: 0(off), 1(on) -- battery conservation mode

/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode = 1 (60%)

+++ Battery Status: BAT1
/sys/class/power_supply/BAT1/manufacturer                   = Celxpert
/sys/class/power_supply/BAT1/model_name                     = L19C4PDB
/sys/class/power_supply/BAT1/cycle_count                    =    316
/sys/class/power_supply/BAT1/energy_full_design             =  60000 [mWh]
/sys/class/power_supply/BAT1/energy_full                    =  52800 [mWh]
/sys/class/power_supply/BAT1/energy_now                     =  31380 [mWh]
/sys/class/power_supply/BAT1/power_now                      =      0 [mW]
/sys/class/power_supply/BAT1/status                         = Not charging

Charge                                                      =   59.4 [%]
Capacity                                                    =   88.0 [%]


Enter fullscreen mode Exit fullscreen mode

This line:

Supported features: charge threshold

shows that my laptop supports charge threshold.

And this section gives me the line I need to add to /etc/tlp.conf:



Parameter value range:
* STOP_CHARGE_THRESH_BAT0: 0(off), 1(on) -- battery conservation mode


Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
vegapunk profile image
vegapunk

Worked for my perfectly! Thanks