asusbat-0.2.1 is not a library.
asusbat 0.2.1
Set battery charge limit on ASUS laptops on Linux with CLI
It is now widely acknowledged that the life span of Li-ion batteries is extended by not charging them to the max. An often recommended battery charge limit is 80.
- License: GPLv3.0
- Authors: github.com/pepa65, github.com/stlenyk
- Repo: https:/github.com/pepa65/asusbat
- After: https://github.com/stlenyk/batterrier
- Required:
- Linux kernel
5.4-rc1
or later (exposing the charge limit variable) systemd
version244
or later (supporting the directives in the included systemd service)
- Linux kernel
- Related Linux kernel module:
asus_nb_wmi
- System variables used:
/sys/class/power_supply/BAT?/*
- Systemd unit file names:
/etc/systemd/system/asusbat-TARGET.service
Features
- Works with supported ASUS laptops
- Show battery info (default)
- Set battery charge limit (needs root privileges)
- Persist the charge limit through creating and enabling systemd services for targets:
hibernate
,hybrid-sleep
,multi-user
,sleep
,suspend
,suspend-then-hibernate
- Unpersist the charge limit by disabling and removing systemd services
- Generate shell completions (bash, elvish, fish, powershell, zsh)
Installation
Download static single-binary
wget https://github.com/pepa65/asusbat/releases/download/0.2.0/asusbat
sudo mv asusbat /usr/local/bin/
sudo chown root:root /usr/local/bin/asusbat
sudo chmod +x /usr/local/bin/asusbat
Using cargo (rust toolchain)
If not installed yet, install a Rust toolchain, see https://www.rust-lang.org/tools/install
Cargo from crates.io
cargo install asusbat
Cargo from git
cargo install --git https://github.com/pepa65/asusbat
Cargo static build (avoid GLIBC incompatibilities)
git clone https://github.com/pepa65/asusbat
cd asusbat
rustup target add x86_64-unknown-linux-musl
export RUSTFLAGS='-C target-feature=+crt-static'
cargo build --release --target=x86_64-unknown-linux-musl
For smaller binary size: upx --best --lzma target/x86_64-unknown-linux-musl/release/asusbat
Install with cargo-binstall
Even without a full Rust toolchain, rust binaries can be installed with the static binary cargo-binstall
:
# Install cargo-binstall for Linux x86_64
# (Other versions are available at https://crates.io/crates/cargo-binstall)
wget github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
tar xf cargo-binstall-x86_64-unknown-linux-musl.tgz
sudo chown root:root cargo-binstall
sudo mv cargo-binstall /usr/local/bin/
Install the musl binary: cargo-binstall asusbat
(Then asusbat
will be installed in ~/.cargo/bin/
which will need to be added to PATH
!)
Usage
asusbat 0.2.1 - Set battery charge limit on ASUS laptops on Linux with CLI
Usage: asusbat [COMMAND]
Commands:
info Print battery info [default command]
limit Set battery charge limit: PERCENT (1..100)
persist Persist charge limit: create and enable systemd services
unpersist Unpersist charge limit: disable and remove systemd services
completions Generate completions: SHELL (bash|elvish|fish|powershell|zsh)
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Root privileges required for: limit, persist & unpersist