Skip to content

Backend & infra

Battery Guard

A cross-platform battery daemon that caps charging, predicts time to target and alerts you on Slack, Telegram, WhatsApp and more.

Role
Personal project
Type
Backend & infra
operating systems
2
alert channels
7
audit log, CSV export
JSONL

How it fits together

  1. Sensorspsutil and /sys: health, cycles, voltage, capacity and ACPI thermals
  2. poll
  3. ControllerDashboard, time-to-target predictor, charge limit and power-profile switching
  4. events
  5. Alert dispatcherEdge-triggered, with cooldowns and quiet hours
  6. send
  7. ChannelsDesktop, Slack, Teams, Discord, WhatsApp, Telegram and ntfy

The problem

Laptop batteries and UPS units wear out early from chronic overcharging and heat. Battery Guard enforces user-defined charge limits, automates power states and alerts you before it becomes a problem.

How I approached it

  1. 1

    Monitor

    Real-time health percentage, cycle count, voltage, design versus actual capacity in Wh, and ACPI motherboard and CPU thermal sensors.

  2. 2

    Limit

    On supported Linux kernels it writes the charge_control_end_threshold file to physically stop charging at the chosen limit.

  3. 3

    Predict

    A time-series estimator uses historical charge and discharge curves to show a time to target.

  4. 4

    Alert

    A notification pipeline sends desktop popups, webhooks (Slack, Teams, Discord), WhatsApp, Telegram and ntfy messages, with cooldown timers and quiet hours.

What I built

  • Automatic Linux power-profile switching (power-saver at low charge, balanced when charging) and sleep safeguards.
  • A system-tray app plus a headless --daemon mode for servers and UPS monitoring, on Ubuntu and Windows.
  • A JSON-lines audit log and one-click CSV reports for asset tracking.

The result

A background service with a dashboard, tray icon and audit trail that limits battery wear on both Linux and Windows workstations.

Built with

  • Python
  • psutil
  • CustomTkinter
  • pystray
  • Webhooks
  • Telegram
  • ntfy