openbattery

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 4 Imported by: 0

README

⚡ openbattery

CI Go Version Latest Release License

A beautiful, responsive macOS terminal battery monitor built with Bubble Tea.

Watch your battery level, power draw, discharge estimates, and health stats in real time — right from your terminal.

openbattery dashboard

Features

  • Live dashboard — battery percentage with gradient progress bar, power draw (watts), remaining time, and charge estimates
  • History sparkline — ▁▂▃▄▅▆▇█ chart of battery level over time with Y-axis labels and time range
  • Smart estimates — remaining time calculated from your average power consumption (last hour / today)
  • Battery health — current max capacity vs design capacity, cycle count
  • Two tabs1 for dashboard, 2 for history, r to refresh, q to quit
  • Responsive layout — adapts seamlessly to any terminal size
  • Persistent history — saves up to 500 samples to ~/.openbattery/history.json
  • Zero config — just run it, no setup needed

Installation

go install github.com/przybylku/openbattery@latest

Or clone and build:

git clone https://github.com/przybylku/openbattery.git
cd openbattery
go build -o openbattery .
./openbattery

Requires macOS (uses pmset and ioreg system utilities).

Data Sources

openbattery reads from two macOS system commands:

  • pmset -g batt — battery percentage, charge status, Apple's time estimate
  • ioreg -rn AppleSmartBattery — amperage (mA), voltage (mV), capacities (mAh), cycle count

All data is processed into a clean TUI with color-coded indicators:

Condition Color
Battery ≥ 50% Green
Battery ≥ 20% Yellow
Battery < 20% Red
Charging Cyan
Charged Green

History

Every 10 seconds, a data point is appended to ~/.openbattery/history.json (keeps last 500 entries). The history tab renders a sparkline of the last 60 samples with the most recent 10 displayed in a table.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package battery provides parsers for macOS battery data sources (pmset and ioreg) and persistent history storage.
Package battery provides parsers for macOS battery data sources (pmset and ioreg) and persistent history storage.
Package ui implements the terminal user interface for openbattery using the Bubble Tea framework.
Package ui implements the terminal user interface for openbattery using the Bubble Tea framework.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL