How can I limit battery charging to 60% capacity?

I have an Asus ROG GL503 laptop, which came pre-installed with Asus Battery Health Charging software. This software gives me the option to limit my battery charging level to 60% to prolong the overall battery lifespan. Whenever I boot using Ubuntu(18.04), my battery keeps charging until it reaches 100%. Is there any method by which I can limit my battery charging up to a certain level?


Solution 1:

I have written a short python script to make switching the thresholds easier on my ROG laptop. (ROG STRIX G731GU).

Please run the script as admin. (e.g. sudo python3 scriptname.py)

power_cfg = open("/sys/class/power_supply/BAT0/charge_control_end_threshold", "r")
print("Current Charge Threshold:")

print(power_cfg.read())
power_cfg = open("/sys/class/power_supply/BAT0/charge_control_end_threshold", "w")
change_opt = input("Change? y/n: ")

if(change_opt == "y"):
    ch_val = input("Enter New Value: ");
power_cfg.write(ch_val);

Please let me know if this works on your machine.