The Battery Charge Level Max Utility similar to macOS's bclm. Therefore, this is the "fake" bclm.
Find a file
2026-03-10 05:46:20 +09:00
bclm Modified to show help message also --help or -h option 2026-03-10 05:46:20 +09:00
README.ja.MD First commit 2026-03-10 05:42:25 +09:00
README.MD First commit 2026-03-10 05:42:25 +09:00

Fakebclm

What is this?

On macOS there is a utility called bclm.
It is a commandline tool that lets you set an upper limit for the internal battery charge of a MacBook.

On GNU/Linux, if the kernel can control the battery, you can set the limit by writing a value to /sys/class/power_supply/BAT0/charge_control_end_threshold.
However, having to type something like echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold every time is a bit of a hassle.
So I thought it would be handy to have a short, simple command on Linux that behaves like macOS's bclm.
This is a "fake" bclm that offers a similar feature under the same command name.

How to use it

This script is written in Bash, so you need Bash available. On almost all distributions Bash is installed by default unless you have deliberately removed it.
The script normally needs to be run with root privileges.

When using the persist and unpersist subcommands, systemd is required. If you are someone who adheres to a strict UNIX philosophy and have chosen an older distribution that does not adopt systemd, or if you are using a specialized environment such as Android or ChromeOS where systemd cannot be employed, these subcommands will not be available.

Fakebclm - Battery Charge Level Max Utility similar to macOS's bclm
Usage:
bclm <subcommand>

Subcommands:
read          Read the current value of battery chage limit level.
write <value> Set the <value> for battery charge limit level.
persist       Create and enable a systemd service that sets battery charge limit level at startup.
unpersist     Disable the systemd sevice that created by "persist" subcommand.

persist / unpersist

When run with the persist option, the script creates and enables a systemd service that resets the battery limit on every reboot.

Battery limits can be reset or overwritten unexpectedly—for example, after a long idle period, when booting another OS, or at other times.
The systemd service protects against such accidental changes. Install it, boot the OS you want to use, then shut down normally; you can start charging with confidence.

Common problems

Setting a value has no effect

Most devices allow battery limits between 50% and 100%.
Values below 50% are either ignored or considered invalid.

"Error: Device does not have the battery control feature or the battery firmware cannot be controlled by Linux kernel." or write errors

Not every device supports setting a charging limit.
Even if a device appears to allow it, it may only be changeable through a BIOS setting or a Windowsspecific application, so the Linux kernel cannot control it.

Many Chromebooks and newer notebooks can set a battery limit. Before using this command, check that the file
/sys/class/power_supply/BAT0/charge_control_end_threshold exists.

If your battery device is not named "BAT0"

The device might be named BAT1, BAT2, etc.
Look inside the /sys/class/power_supply/ directory to find the correct battery device name.
If it differs from BAT0, edit the script and replace every occurrence of BAT0 with your actual device name.

The script also contains a systemd service that is base64encoded.
Decode it, replace BAT0 with the correct device name, then reencode it and put it back into the script.

Disclaimer

This project has no relation whatsoever to the original bclm project (https://github.com/zackelia/bclm).
I am simply a user who frequently uses the original bclm command.

Do not contact the original bclm project regarding this project.
Likewise, do not post any questions about the original bclm project here.

When mentioning this project, do not refer to any relationship with the original bclm project.

License

This script is provided in the public domain.