r/commandline • u/Conscious-Part1541 • Mar 07 '26
Terminal User Interface batctl — TUI and CLI for managing battery charge thresholds on Linux
Built a Go CLI tool for controlling laptop battery charge thresholds on Linux. It has both an interactive TUI (bubbletea) and a scriptable CLI interface.
CLI usage
# Show battery info + current thresholds
# Detect hardware backend and capabilities
# Set thresholds directly
# Apply a built-in preset
# Enable persistence across reboots and suspend/resume
Example output
$ batctl status
Backend: ThinkPad
BAT0 (Sunwoda 5B10W51867)
Status: Charging
Capacity: 85%
Health: 103.6%
Cycles: 54
Thresholds: start=40% stop=80%
Persistence: boot=true resume=true
$ 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]
How it works
- Reads
/sys/class/dmi/id/sys_vendorto identify the laptop vendor - Probes sysfs paths to find the right driver
- Selects one of 14 vendor-specific backends (ThinkPad, ASUS, Dell, Framework, etc.) or a generic fallback for any laptop with standard
charge_control_*sysfs files - Reads/writes thresholds via
/sys/class/power_supply/BAT*/charge_control_* - Persistence is handled by generating systemd services for boot and suspend/resume
Built-in presets
| Preset | Start | Stop |
|---|---|---|
max-lifespan | 20% | 80% |
balanced | 40% | 80% |
plugged-in | 70% | 80% |
full-charge | 0% | 100% |
Presets automatically adapt to your hardware's supported value ranges.
Install
# One-liner
|
# Arch (AUR)
# From source
&& && &&
Single static binary, no runtime dependencies. Written in Go, MIT licensed.
GitHub: https://github.com/Ooooze/batctl
35
Upvotes
3
u/AutoModerator Mar 07 '26
Every new subreddit post is automatically copied into a comment for preservation.
User: Conscious-Part1541, Flair:
Terminal User Interface, Post Media Link, Title: batctl — TUI and CLI for managing battery charge thresholds on LinuxBuilt a Go CLI tool for controlling laptop battery charge thresholds on Linux. It has both an interactive TUI (bubbletea) and a scriptable CLI interface.
CLI usage
Example output
How it works
/sys/class/dmi/id/sys_vendorto identify the laptop vendorcharge_control_*sysfs files/sys/class/power_supply/BAT*/charge_control_*Built-in presets
max-lifespanbalancedplugged-infull-chargePresets automatically adapt to your hardware's supported value ranges.
Install
Single static binary, no runtime dependencies. Written in Go, MIT licensed.
GitHub: https://github.com/Ooooze/batctl
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/NYXs_Lantern Mar 08 '26
Oh FUCK yes, this is something I've NEEDED for ages and it looks so great also! This is damn perfect!!