Skip to main content

asus-charge-control

Set your recent ASUS notebook's maximum charge level on Linux.

Recent ASUS notebooks come with a Windows application to set the maximum battery charge level, in order to reduce stress on the battery and prolong its lifespan. On Linux kernels >= version 5.4, the asus_nb_wmi kernel module exposes a sysfs object to manage this setting.

Getting or setting the charge end threshold is rather verbose:

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

$ echo 80 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold
80

asus-charge-control offers a quicker way.

Installation

asus-charge-control should work with any device running a recent kernel (>= 5.4) with the asus_nb_wmi module loaded. Use lsmod | grep asus_nb_wmi to check; if you see a line like asus_nb_wmi 32768 0, then the module is running.

It has been tested with the following ASUS notebooks:

  • ASUS VivoBook 15 X512DA

A Python version >= 3.7 is necessary to run this script. Most Linux distributions come with the right version. To verify that Python is installed on Debian/Ubuntu-based distributions, use apt:

sudo apt install python3

As root privileges are necessary to set the charge end threshold, asus-charge-control should be installed as a global package:

sudo pip install --system asus-charge-control

DANGER: Normally, Python packages should not be installed with sudo, as they may execute arbitrary code. I encourage you to read setup.py before installation.

Usage

You can get the current charge end threshold by calling asuscharge from the command line:

$ asuscharge
Current charge end threshold: 100%

Setting the charge end threshold requires root privileges:

$ sudo asuscharge 80
Successfully set charge end threshold to 80%

Note: The charge end threshold resets back to 100% when the system is rebooted.

You can use a cron job to set the charge end threshold automatically on boot. To do so, find the path of the asuscharge command like so:

$ which asuscharge
/usr/local/bin/asuscharge

Modify the root user's crontab file:

sudo crontab -e

Add the following line to the end of the file:

@reboot /usr/local/bin/asuscharge MAX

Replace MAX with the charge end threshold you would like, then save and close the file.

Development

You can use the asuscharge package in your own applications. The package offers a ChargeThresholdController object, with a settable end_threshold property. It also offers three methods to check if the user's platform supports the charge end threshold feature: supported_platform(), supported_kernel(), and module_loaded().

Version history

  • 1.0.2 (2020-12-28)

    • (fix) MAX wasn't properly range checked for a value between 60-100.
    • (feature) added --force to set a threshold value beneath 60.
  • 1.0.1 (2020-12-06)

    • (fix) supported_kernel() returned an incorrect value for Linux kernel versions > 5.9.
  • 1.0.0 (2020-12-04)

    • Initial release.

Release files for asus-charge-control 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asus-charge-control 1.0.3
File Size Uploaded
asus-charge-control-1.0.3.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asus-charge-control 1.0.3
File Interpreter ABI Platform
asus_charge_control-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / asus-charge-control-1.0.3.tar.gz

Download URL asus-charge-control-1.0.3.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2b76356e536a08b9b84f48c41dae72c09c4db2b15cf883636e9796ef1b9adbb5
BLAKE2b-256 checksum
How to use checksums
ce8ec2547d6af9f44258d3f81ab42bfdc1d2012f3aa0d41fc8eb0eea1551f761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

Release files / asus_charge_control-1.0.3-py3-none-any.whl

Download URL asus_charge_control-1.0.3-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0d7b96705e8094aecc7eab6d095cb1bb2c1e622001b499179b5c868e531c893
BLAKE2b-256 checksum
How to use checksums
75688c0634982218d7dad4d3516def30fb6d140e65ee3c34aa9d6f77dc03e4f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page