macOS battery and power monitor with real-time Textual TUI, SQLite history, and CSV/JSON export
Project description
powermonitor: macOS Battery Monitor & MacBook Power Usage TUI โก๐
powermonitor is an open-source macOS battery monitor, MacBook charging wattage checker, and real-time terminal power usage dashboard. It shows live watts, voltage, amperage, battery percentage, charging state, charger details, historical charts, SQLite history, battery health trends, and CSV/JSON export.
Use it when you want a terminal-native alternative to repeatedly checking Activity Monitor, System Information, pmset, or raw ioreg output.
Package: powermonitor ยท Command: powermonitor ยท Platform: macOS ยท Docs: https://narumiruna.github.io/power-monitor/
Quick start
Run the Mac power monitor without installing a persistent tool:
uvx powermonitor
Or install the command as an isolated tool:
uv tool install powermonitor
powermonitor
Why use powermonitor?
- โก Real-time MacBook wattage: live actual power draw and negotiated charger watts.
- ๐ Battery status at a glance: battery percentage, capacity, charging state, and AC power state.
- ๐ USB-C and MagSafe charger diagnostics: charger name, manufacturer, and negotiated power when macOS exposes them.
- ๐ Terminal charts: rolling Textual dashboard for recent power usage.
- ๐ฅ Battery health trend: summarize maximum capacity changes over days or weeks.
- ๐พ Local SQLite history: automatic logging under
~/.powermonitor/by default. - ๐ค CSV/JSON export: analyze MacBook battery and charging data in spreadsheets, notebooks, or scripts.
- ๐งฐ Scriptable CLI: history, stats, health, export, cleanup, and config commands.
- ๐ Reliable macOS collection: direct IOKit/SMC integration with an
ioregfallback.
Common use cases
- Check whether a USB-C charger, cable, dock, or power bank is delivering expected wattage.
- Watch battery drain while compiling, gaming, rendering video, or running benchmarks.
- Compare MacBook power usage before and after changing apps, settings, or peripherals.
- Export power readings for performance reports or battery experiments.
- Track battery capacity trends without a cloud account or background service.
Feature overview
| Need | powermonitor helps by |
|---|---|
| Real-time macOS power monitoring | Showing live watts, voltage, amperage, battery %, and charging state |
| Charger debugging | Displaying negotiated wattage, charger name, and manufacturer when available |
| Battery health tracking | Comparing capacity readings across days to reveal degradation trends |
| Repeatable experiments | Saving local SQLite history and exporting CSV/JSON data |
| Terminal-native workflow | Running as a responsive Textual TUI or focused CLI commands |
| Broad Mac compatibility | Trying IOKit/SMC first, then falling back to ioreg collection |
Installation
uv (recommended)
uv tool install powermonitor
Run without installing
uvx powermonitor
pipx
pipx install powermonitor
pip
python -m pip install powermonitor
uv tool install or pipx install keeps the CLI isolated from project environments.
Usage
Launch the real-time TUI
powermonitor
Useful launch options:
powermonitor --interval 2.0
powermonitor --stats-limit 200 --chart-limit 120
powermonitor --debug
| Option | Purpose | Default |
|---|---|---|
--interval, -i |
Data collection interval in seconds | 1.0 |
--stats-limit |
Number of readings used for rolling statistics | 100 |
--chart-limit |
Number of readings shown in the chart | 60 |
--debug |
Enable debug logging | false |
Keyboard controls: q or Esc quits, r refreshes, and c clears history after confirmation.
โโ powermonitor โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Real-Time Power โ Statistics โ
โ โก 45.2W / 67W โ Last 100 readings โ
โ ๐ 72% 20.0V ร 2.26A โ Avg: 42.3W โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Power Chart (Last 60 readings) โ
โ 55W โค โญโโโฎ โ
โ 45W โค โญโโโโฏ โฐโโโฎ โ
โ 35W โคโโโฏ โฐโ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ [q] Quit [r] Refresh [c] Clear History โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The dashboard adapts to terminal size: tall terminals stack panels vertically, short wide terminals place summary panels side by side, and narrow terminals avoid unreadable columns.
CLI command reference
| Command | What it does |
|---|---|
powermonitor |
Launch the real-time Textual dashboard |
powermonitor history |
Show recent saved readings |
powermonitor stats |
Show database count, date range, size, and path |
powermonitor health |
Summarize battery capacity changes over time |
powermonitor export OUTPUT |
Export readings as CSV or JSON |
powermonitor cleanup |
Delete old readings or clear the database |
powermonitor config |
Create, inspect, and validate config.toml |
Export MacBook battery data
powermonitor export data.csv
powermonitor export data.json
powermonitor export data.csv --limit 1000
powermonitor export backup.txt --format csv
View history and stats
powermonitor history
powermonitor history --limit 50
powermonitor stats
Analyze battery health
powermonitor health
powermonitor health --days 60
Clean up local data
powermonitor cleanup --days 30
powermonitor cleanup --all
Configuration
powermonitor uses sensible defaults and supports an optional config file at ~/.powermonitor/config.toml.
powermonitor config init
powermonitor config show
powermonitor config validate
Example config:
[tui]
interval = 1.0
stats_limit = 100
chart_limit = 60
[database]
path = "~/.powermonitor/powermonitor.db"
[cli]
default_history_limit = 20
default_export_limit = 1000
[logging]
level = "INFO"
Configuration priority: CLI arguments > config file > defaults.
Requirements
- macOS 12.0+ Monterey or later
- Python 3.13+
- No root privileges required
Sensor availability varies by Mac model, charger, cable, dock, and macOS version. powermonitor records the values macOS exposes.
Data and privacy
- Readings are stored locally in SQLite at
~/.powermonitor/powermonitor.dbby default. - No cloud account, telemetry service, or daemon is required.
- Data leaves your machine only when you explicitly export it with
powermonitor export. - Cleanup is manual via
powermonitor cleanup.
Architecture
powermonitor keeps collection, storage, CLI, and UI concerns separate:
macOS power APIs
โโ IOKit/SMC collector (preferred)
โโ ioreg collector (fallback)
โ
PowerReading dataclass
โ
SQLite database + live Textual widgets
โ
CLI history, stats, health, cleanup, and export commands
Core modules live under src/powermonitor/:
cli.py: Typer CLI entry point and subcommands.collector/: IOKit/SMC andioregdata collection.database.py: SQLite persistence.config.pyandconfig_loader.py: validated TOML configuration.tui/: Textual application, widgets, and adaptive layout.
Documentation
Full documentation is available at https://narumiruna.github.io/power-monitor/:
Power Monitor vs built-in macOS tools
macOS includes Activity Monitor, System Information, pmset, and ioreg, but they are not optimized for continuous terminal monitoring. powermonitor combines live power metrics, MacBook battery status, charger details, SQLite history, charts, health summaries, cleanup, and exports in one developer-friendly CLI.
FAQ
What is powermonitor?
powermonitor is a Python CLI and terminal UI for macOS power monitoring. It shows real-time MacBook wattage, battery status, voltage, amperage, charger information, history, charts, and battery health data.
Does it work on Apple Silicon and Intel Macs?
It is designed for macOS and uses IOKit/SMC data when available, with an ioreg fallback for broad compatibility. Exact sensors can vary by Mac model and macOS version.
Can powermonitor show USB-C charger wattage?
Yes, when macOS exposes the information. powermonitor displays negotiated charger watts, charger name, and manufacturer when available.
Where is power history stored?
By default, readings are stored locally in SQLite at ~/.powermonitor/powermonitor.db. You can change the path in ~/.powermonitor/config.toml.
Can I export MacBook charging and battery data?
Yes. Use powermonitor export data.csv or powermonitor export data.json.
Development
uv sync
make format
make lint
make type
make test
make all
Build release artifacts:
uv build --no-sources
Build the MkDocs website locally:
uv sync --group docs
uv run mkdocs serve
uv run mkdocs build --strict
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file powermonitor-0.0.12-py3-none-any.whl.
File metadata
- Download URL: powermonitor-0.0.12-py3-none-any.whl
- Upload date:
- Size: 37.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d62d0423b4a915b6c6f826a3d03c3551d85bb55f4829a95ebf34e3a5e563610
|
|
| MD5 |
98a0969b3cae048f6eecb9b26906d95f
|
|
| BLAKE2b-256 |
fe597d7bffdb8b8a7757965139ceb32b4d1928cd0b5048fc14ee508b6e282870
|