Simply load the charging thresholds for ASUS laptops on Linux with bat

bat is a simple command line tool to easily set and check the ASUS battery charging stop threshold (for laptops that support it) to save battery life.

According to his wiki, the aim is to ask “replicate the functionality ASUS Battery Health charging Utility for ASUS laptops running Windows that aims to extend battery life“.

I’ve already covered how to limit battery charging for ASUS laptops on Linux (set a charge limit), but with the help of this tool you can easily change the charge limit, reset it and see the current charge threshold level. bat can also print out the current battery status and charge status.

Under the hood, bat uses systemd services to keep the battery charge threshold between reboots and after waking up from hibernation. To use bat you need systemd 244 or newer (e.g. Ubuntu 20.04 and newer, Debian Bullseye and Sid, Fedora 32 or newer, openSUSE Leap 15.3 etc.), Bash and at least Linux 5.4, but for some newer ASUS laptops you will need a newer kernel (more on this in the link below).

For more information, please see my first article on Limiting Battery Charging for ASUS Laptops.. I also recommend following the first steps from this article (don’t create the systemd service; if so, stop and disable it with sudo systemctl stop battery-charge-threshold; sudo systemctl disable battery-charge-threshold) to make sure that your ASUS laptop actually supports battery charging limitation in Linux. Not all ASUS laptops support setting a battery charge threshold, so this may or may not work for you depending on your ASUS laptop model. There isn’t a list of supported devices that I could find.

[[Edit]]In some cases this may not work properly after resuming from suspend (so far only reported under Ubuntu) (do not set a loading threshold). Error Report here.

You Might Also Like: 3 Tools To View Linux Laptop Battery Information From Command Line

Install and use bat to limit battery charging for ASUS laptops running Linux

To use bat, first install the binary file on his GitHub publishing page. Download the bat file and place it in your home folder. Then open up a terminal and install it on /usr/local/bin with the following command:

sudo install bat /usr/local/bin

If you already have a binary called bat (e.g. bat), rename it to something else.

To display the current charge threshold with bat, use -t or --threshold:

bat -t

If you’ve never set a charge threshold for the battery, this command should return “100” which means the battery will be fully charged.

To set a threshold value for the battery to stop charging with bat, use:

sudo bat -t <CHARGE_THRESHOLD>

For example, to only charge the laptop battery to 60% and then stop charging, use:

sudo bat -t 60

By default, this new battery threshold is only used for the current session and is reset when the system restarts. To make the change permanent, use -p or --persist:

sudo bat -p

If you want to undo this and only want to use the current charge threshold for the current session (prevent it from persisting after a system reboot), use -r or --reset:

sudo bat -r

If you want to get rid of the battery charge thresholds and have the ASUS laptop fully charge (to 100%), simply reset the threshold to 100 using:

sudo bat -t 100

bat can also display the current battery level (-c or --capacity) and print the charging status (-s or --status).

You may also be interested in: How to Embed the Numpad on Some ASUS Laptops’ Touchpad to Work on Linux

Related Posts