Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

bat

> 编程语言
Open source

Battery management utility for Linux laptops.

61.5K stars0 likes2 views
WebsiteGitHub

About

Battery management utility for Linux laptops.

bat

…

About

The goal is to replicate the functionality of the ASUS Battery Health Charging utility for ASUS laptops on Windows which aims to prolong the battery's life-span 1 2.

Disclaimer

This has been reported to only work with some ASUS and Lenovo ThinkPad laptops only. For Dell systems, see smbios-utils, particularly the smbios-battery-ctl command, or install it using your package manager. For other manufacturers there is also TLP.

There have also been some problems setting the charging threshold inside of a virtual machine.

Installation

Pre-compiled binaries (Linux x86-64) are available from the GitHub releases page, the latest of which can be downloaded from here.

After downloading the binary, give it permission to execute on your system by running the following command. For example, assuming the binary is located in the user's Downloads folder:

bash
chmod +x $HOME/Downloads/bat

Alternatively, the application can be build from source by running the following command in the root directory of this repository. This requires a working version of Make and Go.

bash
make build

Tip: Create a symbolic link of the resulting binary in a directory that is in the $PATH environment variable such as /usr/local/bin/. This will allow any user to execute the program from anywhere on the system.

bash
ln -s $HOME/Downloads/bat /usr/local/bin/bat

You can also rename the binary to something else if another program with the same name already exists i.e. bat.

Examples

bash
# Print the current battery charging threshold.
bat threshold

# Set a new charging threshold, say 80% (requires superuser
# permissions).
sudo bat threshold 80

# Persist the current charging threshold setting between restarts
# (requires superuser permissions).
sudo bat persist

Requirements

Linux kernel version later than 5.4-rc1 which is the earliest version to expose the battery charging threshold variable.

To persist the threshold setting between restarts, the application relies on systemd version 244 or later, which is bundled with most Linux distributions.

Issues· 10 open

View all issuesOpen on GitHub
  • #117

    Laptop charging past the set threshold

    Updated Sep 2, 2026
  • #118

    bug: clamp battery health values over 100

    buggood first issueUpdated Sep 3, 2025
  • #108

    issue: persist does not work for me (it worked in the past)

    bugUpdated Feb 9, 2025
  • #97

    bug: threshold ranges on ThinkPads

    Updated Dec 19, 2024
  • #102

    bug: kernel regression in 6.12 removes the charging threshold

    bugUpdated Dec 17, 2024
  • #104

    issue: Charging threshold setting not found.

    bugUpdated Dec 11, 2024
  • #85

    build: package bat for NixOS

    bugUpdated Mar 1, 2024
  • #74

    build: create additional Make targets

    enhancementgood first issueUpdated Oct 5, 2023

> Tags

Goasusbashbatterybattery-level

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedNov 29, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言