Skip to content

A Next.js web app that calculates Windows laptop battery health by parsing PowerCfg battery reports.

Notifications You must be signed in to change notification settings

Derojuu/BatteryHealthChecker

Repository files navigation

Battery Health Checker 🔋

A modern web application built with Next.js that helps you check your laptop's battery health by analyzing battery reports from Windows (PowerCfg) and Mac (system_profiler).

📖 Overview

The Battery Health Checker is a user-friendly web application that calculates your laptop battery's health percentage by parsing Windows PowerCfg battery reports or Mac system_profiler battery reports. It provides an intuitive interface to upload your battery report and instantly see your battery's current health status.

✨ Features

  • Simple Upload Interface: Easy-to-use file upload for battery reports
  • Accurate Health Calculation: Calculates battery health percentage based on design capacity vs full charge capacity
  • Modern UI: Clean, responsive design built with Tailwind CSS and shadcn/ui components
  • Error Handling: Comprehensive error messages for invalid files or parsing issues
  • Windows & Mac Integration: Works seamlessly with Windows PowerCfg battery reports and Mac system_profiler battery reports

🚀 Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Windows or Mac operating system (for generating battery reports)

Installation

  1. Clone the repository:
git clone https://github.com/Derojuu/BatteryHealthChecker.git
cd battery-health-checker
  1. Install dependencies:
npm install
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser

Production Build

npm run build
npm start

🔧 How to Use

Step 1: Generate Battery Report

For Windows:

Run this command in Windows PowerShell or Command Prompt:

powercfg /batteryreport /output "C:\battery-report.html"

For Mac:

Run this command in Terminal:

system_profiler SPPowerDataType > battery-report.txt

Step 2: Upload and Analyze

  1. Open the Battery Health Checker web application
  2. Click "Choose File" and select the generated battery-report.html (Windows) or battery-report.txt (Mac) file
  3. Click "Calculate Health" to get your battery health percentage
  4. View your battery health percentage and any relevant warnings

Understanding Results

  • 90-100%: Excellent battery health
  • 80-89%: Good battery health
  • 70-79%: Fair battery health
  • Below 70%: Consider battery replacement

🛠 Tech Stack

  • Framework: Next.js 15.3.1 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS v4
  • UI Components: Radix UI primitives with shadcn/ui
  • Icons: Lucide React
  • Font: Geist Sans & Geist Mono

📁 Project Structure

battery-health-checker/
├── app/                    # Next.js App Router directory
│   ├── page.tsx           # Main battery checker component
│   ├── layout.tsx         # Root layout with fonts and metadata
│   └── globals.css        # Global styles and Tailwind imports
├── components/ui/         # Reusable UI components
│   ├── button.tsx         # Custom button component
│   ├── card.tsx          # Card layout components
│   ├── input.tsx         # File input component
│   ├── label.tsx         # Form label component
│   └── separator.tsx     # Visual separator component
├── lib/
│   └── utils.ts          # Utility functions (cn helper)
├── public/               # Static assets
└── package.json         # Project dependencies and scripts

🧩 Key Components

Main Battery Checker (app/page.tsx)

  • File upload handling
  • Battery report parsing logic
  • Health percentage calculation
  • Error handling and user feedback

UI Components (components/ui/)

  • Modular, reusable components built with Radix UI
  • Consistent styling with Tailwind CSS
  • Accessible and responsive design

🔍 How It Works

  1. File Upload: Users upload their PowerCfg battery report HTML file (Windows) or system_profiler text file (Mac)
  2. Text Parsing: The application extracts "DESIGN CAPACITY" and "FULL CHARGE CAPACITY" values (Windows) or "Design Capacity" and "Full Charge Capacity" (Mac)
  3. Health Calculation: Battery health = (Full Charge Capacity / Design Capacity) × 100
  4. Result Display: Shows the calculated percentage with appropriate styling

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is open source and available under the MIT License.

🐛 Troubleshooting

Common Issues

  • "Capacity values not found": Ensure you're uploading a valid PowerCfg (Windows) or system_profiler (Mac) battery report
  • "Failed to read or parse": Check that the file isn't corrupted and is in the correct format (HTML for Windows, TXT for Mac)
  • No file selected: Make sure to select a file before clicking "Calculate Health"

Getting Help

If you encounter issues:

  1. Check that your battery report was generated correctly
  2. Ensure the file is the complete HTML report from PowerCfg
  3. Try regenerating the battery report and uploading again

🌟 Acknowledgments

About

A Next.js web app that calculates Windows laptop battery health by parsing PowerCfg battery reports.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published