Tag: reboot

  • Persist Asus battery charge limit after reboot on Fedora

    Despite many issues reported over the last years about this problem, as of Fedora Kinoite 44 on kernel 7.1.3 with KDE Plasma 6.7.2 it is still not possible to persist the battery’s maximum charge limit upon a reboot. To be fair it is mainly due to the laptop manufacturers’ way of resetting the value to 100% charge level upon each boot.

    Having to remember and set this value upon each boot may seem like no task but it becomes a real nuisance after each update. Running Fedore Kinoite means that a reboot is needed after each system upgrade so it happens more often than perhaps in the past when only a kernel upgrade needed a reboot.

    In this scenario the 2024 Asus TUF laptop does accept custom set charge limits providing plenty of flexibility for multiple use cases. I would usually set it at 50% level unless the laptop is needed on batteries later where it can then be raised to 80% prior to leaving AC power. This should ensure future battery health for many years.

    The “Charge Limit” value is set inside the “Power Management” settings under “Configure Advanced Settings” in the top right corner. I would guess each laptop would have different options depending on what the hardware exposes to the system. By default the value is 100% after boot so simply change it to the value you desire. You will be asked to authenticate as it is a system wide setting.

    Avoiding this cumbersome task is rather simple though. Until it gets fixed we can just set the charge limit programmatically upon each boot. There are several ways to skin the cat so the following is in my opinion the simplest and cleanest one. Using the tmpfiles.d service we can do this pretty fast (if curious there are many systemd-tmpfiles uses).

    First we can actually check the current battery charge limit value (please note BAT0 may instead be BATn on your device, usually 0-4):

    $ cat /sys/class/power_supply/BAT0/charge_control_end_threshold
    100

    Then let us set and get the new value through here instead of using the GUI:

    $ echo 50 > /sys/class/power_supply/BAT0/charge_control_end_threshold
    $ cat /sys/class/power_supply/BAT0/charge_control_end_threshold
    50

    This would work fine for a quick change but now we will create the instructions to tmpfiles to do it at boot instead:

    $ sudo vim /etc/tmpfiles.d/asus-battery.conf
    $ cat /etc/tmpfiles.d/asus-battery.conf
    # Type  Path                                                 Mode UID  GID  Age Argument
    w-      /sys/class/power_supply/BAT0/charge_control_end_threshold -    -    -    -   50
    

    The formatting needs to be as is, so please bear in mind that depending on the width of your screen it may not be displayed properly right here, so if you copy and paste the content into a text editor it would be easier to see. The first line is just a comment for reference so you get the idea of each column, the real action happens in the second line. Here the value of 50 is written into “/sys/class/power_supply/BAT0/charge_control_end_threshold” just as we did manually before.

    After next reboot the system will automatically change the charge limit, to 50% in this case. Obviously just change this value to the desired default. Please note that you can always later modify temporarily the limit in the GUI settings as shown earlier. This last change would apply until next reboot only.