Control the charging of battery in Ubuntu

I am using a ASUS lap top of model: ASUS VivoBook 15 X510. I have dual booted it with Windows 10 Pro and Ubuntu 20.04.

In 'ASUS laptops' there is a driver named: 'ASUS Battery Health Charging'. This driver is for controlling the battery charging capacity of the laptop and works only in Widows operating system only. You can see the user interface of the driver from here. There you can see that I have selected maximum life span mode which is only 60% is charging while the laptop is plugged into power. And once I change the settings as I proffered, it does not change in each time I log into the Windows OS.

But when the Ubuntu OS is booted, the driver is not working and it charges up to 100% maxium. ( I know it is not good for the battery health charging up to 100% always). In Ubuntu I could not find any driver to control the level of battery charging.

But I could find this command and I used it.

echo 60 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

This command was successful and after running the command the battery level did not go beyond 60%. The output can be seen from here. But whenever I reboot the computer it again changes the settings to 100% maximum charging. So, I need to enter above code from the terminal at each time I log into the Ubuntu OS in order to limit the charging level to 60% maximum.

I checked for a reliable method in different forums dedicated to Ubuntu also, but could not find a proper solution.

Can somebody tell me the way to limit the charging of the battery of laptop in Ubuntu OS permanently?

Thanks in advance.


Solution 1:

Try the following lines of commands from the bash terminal:

crontab -e

  • Then select the nano editor
  • Add the following command

@reboot root echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold

  • Then, save and quit

This should configure the battery settings not to exceed the battery charging level beyond 60% when rebooted.