GitPedia

Batctl

⚡ Battery charge threshold manager for Linux laptops

From Ooooze·Updated June 25, 2026·View on GitHub·

**batctl** is a ⚡ Battery charge threshold manager for Linux laptops The project is written primarily in Go, distributed under the MIT License license, first published in 2026. Key topics include: battery, charge-threshold, cli, go, laptop.

Latest release: v2026.3.13batctl 2026.3.13
March 11, 2026View Changelog →
<p align="center"> <h1 align="center">⚡ batctl</h1> <p align="center"> <strong>Battery charge threshold manager for Linux laptops</strong> </p> <p align="center"> <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#supported-hardware">Hardware</a> • <a href="#presets">Presets</a> • <a href="#persistence">Persistence</a> </p> </p> <br>

batctl is a terminal UI and CLI tool that lets you control battery charge thresholds on Linux.
Set start/stop charge levels to extend battery lifespan, choose from built-in presets,
and persist your settings across reboots — all from a single, zero-dependency binary.

<p align="center"> <img src="demo.gif" alt="batctl demo" width="800"> </p>

Why batctl?

Most laptops support charge thresholds in hardware, but the Linux interface is fragmented:
each vendor exposes different sysfs paths, value ranges, and quirks.
Tools like TLP are powerful but heavy and config-file-driven.

batctl gives you:

  • One binary, zero config — auto-detects your hardware and shows what's possible
  • Interactive TUI — see battery health, adjust thresholds with arrow keys, pick presets
  • Scriptable CLIbatctl set --stop 80 for automation and dotfiles
  • 16+ vendor backends — from ThinkPad to Apple Silicon, with a generic fallback
  • Persistence — survives reboots and suspend/resume via systemd

Installation

Quick install (any distro)

bash
curl -fsSL https://raw.githubusercontent.com/Ooooze/batctl/master/install.sh | sudo bash

To uninstall:

bash
curl -fsSL https://raw.githubusercontent.com/Ooooze/batctl/master/install.sh | sudo bash -s -- --uninstall

From source

bash
git clone https://github.com/Ooooze/batctl.git cd batctl make sudo make install

Arch Linux / Omarchy (AUR)

bash
yay -S batctl-tui

Or manually:

bash
makepkg -si

Pre-built binary

Download from Releases, then:

bash
chmod +x batctl sudo cp batctl /usr/bin/

Usage

Interactive TUI

Launch the full terminal interface (requires root for write operations):

bash
sudo batctl

Controls:

KeyAction
/ j kNavigate between fields
/ h lAdjust value (±1)
H LAdjust value (±5)
EnterToggle edit mode
EscCancel edit
pOpen preset picker
aApply current thresholds
sSave config + enable persistence
rRefresh battery info
qQuit

CLI Commands

bash
# Show battery info, thresholds, and persistence status batctl status # Detect hardware and show capabilities batctl detect # Set thresholds directly sudo batctl set --start 40 --stop 80 # Apply a built-in preset sudo batctl set --preset max-lifespan # Apply thresholds from config (used by systemd on boot) sudo batctl apply # Enable persistence (systemd services: boot + resume) sudo batctl persist enable # Check persistence status batctl persist status # Disable persistence and clean up sudo batctl persist disable

Example: batctl status

Backend: ThinkPad

BAT0 (Sunwoda 5B10W51867)
  Status:     Charging
  Capacity:   85%
  Health:     103.6%
  Cycles:     54
  Energy:     48.3 / 52.8 Wh (design: 51.0 Wh)
  Power:      20.1 W
  Thresholds: start=40% stop=80%
  Behaviour:  auto (available: auto, inhibit-charge, force-discharge)

Persistence:  boot=true  resume=true

Example: batctl detect

Vendor:  LENOVO
Product: 21AH00FGRT
Backend: ThinkPad
Capabilities:
  Start threshold:    true (range: 0..99)
  Stop threshold:     true (range: 1..100)
  Charge behaviour:   true
Batteries: [BAT0]

Presets

Built-in presets adapt automatically to your hardware's supported value ranges:

PresetStartStopDescription
max-lifespan20%80%Best for battery longevity. Ideal if you're mostly plugged in.
balanced40%80%Good mix of available capacity and long-term health.
plugged-in70%80%Narrow band for always-connected workstations.
full-charge0%100%No restrictions. Use when you need maximum runtime.
bash
sudo batctl set --preset balanced

On hardware with limited options (e.g. Samsung with only 80/100),
presets snap to the nearest supported value.

Supported Hardware

batctl auto-detects your laptop vendor via DMI and probes sysfs for the right driver.
If no specific backend matches, the generic fallback is used for any laptop
exposing standard charge_control_{start,end}_threshold files.

VendorStartStopBehaviourKernel Driver
Acer80 or 100acer-wmi-battery
Lenovo ThinkPad0–991–100thinkpad_acpi
ASUS0–100¹asus_wmi
Dell50–9555–100dell_laptop
Lenovo IdeaPadon/off²ideapad_laptop
Huawei MateBook0–991–100huawei_wmi
Samsung80 or 100samsung_laptop
LG Gram80 or 100lg_laptop
MSIauto³10–100msi_ec
Framework0–99⁴1–100cros_charge-control
System760–991–100system76_acpi
Sony VAIO50/80/100sony_laptop
Toshiba/Dynabook80 or 100toshiba_acpi
Tuxedo (Clevo)discrete⁵discrete⁵clevo_acpi
Apple Siliconauto³80 or 100macsmc_power
Microsoft Surface0–99⁶1–100surface_battery
Generic fallback0–991–100any sysfs

<sup>¹ Some ASUS models only accept 40, 60, or 80</sup><br>
<sup>² Conservation mode: fixed threshold (usually 60%)</sup><br>
<sup>³ Start threshold is computed by hardware from stop value</sup><br>
<sup>⁴ Start threshold requires EC firmware v3</sup><br>
<sup>⁵ Tuxedo start: 40/50/60/70/80/95 — stop: 60/70/80/90/100</sup>
<sup>⁶ Requires linux-surface kernel; start threshold availability varies by model</sup>

Persistence

By default, charge thresholds reset on reboot or resume from suspend.
batctl solves this with a one-command setup:

bash
sudo batctl persist enable

This installs:

ComponentPathPurpose
Config file/etc/batctl.confStores your threshold values
Boot service/etc/systemd/system/batctl.serviceApplies thresholds on boot
Resume service/etc/systemd/system/batctl-resume.serviceRestores thresholds after suspend/resume

To disable and remove everything:

bash
sudo batctl persist disable

How It Works

batctl
├── Reads /sys/class/dmi/id/sys_vendor → identifies laptop vendor
├── Probes sysfs paths → confirms driver availability
├── Selects matching backend (or generic fallback)
├── Reads/writes /sys/class/power_supply/BAT*/charge_control_*
└── Manages systemd services for persistence

All operations go through the kernel's standard sysfs interface.
No direct hardware access, no custom kernel modules required.

Architecture

batctl/
├── cmd/batctl/          → CLI entry point (cobra)
├── internal/
│   ├── backend/         → 16 vendor backends + generic + auto-detection
│   ├── battery/         → sysfs read/write helpers, battery info
│   ├── persist/         → systemd services, config file
│   ├── preset/          → built-in presets with hardware adaptation
│   └── tui/             → bubbletea TUI (dashboard, presets, styles)
├── configs/             → systemd service templates
├── Makefile
└── PKGBUILD             → Arch Linux package

Requirements

  • Linux with a kernel that includes your laptop's battery driver
  • Root access (sudo) for writing thresholds and managing persistence
  • No runtime dependencies — single static binary

Community Projects

  • threshpad — GNOME Shell extension for batctl

Contributing

Contributions are welcome! Areas where help is especially appreciated:

  • New vendor backends — if your laptop isn't detected, check batctl detect output and open a PR
  • Testing — try batctl on your hardware and report what works
  • Packaging — help with Fedora, Debian, NixOS packages

If batctl saved your battery some cycles, consider buying me a coffee in crypto:

CurrencyNetworkAddress
BTCBitcoinbc1qflyxz75wkcyet89cttanyv7ws98lf8wjezdydq
ETHEthereum0xAfAA1CEdb10ECfC696C9984e857c813CB1871b4C
USDTTRC-20TSgwHUf6tiuJgFmaerb3TyTjggoP5cPecb
TONTONUQA1SYTIdmH7iPNcUtbOtQXtCLPzTYeR8YxCdxksU8HMhkSe

License

MIT

Contributors

Showing top 1 contributor by commit count.

View all contributors on GitHub →

This article is auto-generated from Ooooze/batctl via the GitHub API.Last fetched: 6/25/2026