Skip to content

codehelping.com

No. 1 For Project and Interview

  • Home
  • Projects
  • Blog
  • Contact Us

Build a Desktop Battery Notifier in Python | CodeHelping Python Projects

Posted on August 7, 2025August 7, 2025 By Omkar Pathak No Comments on Build a Desktop Battery Notifier in Python | CodeHelping Python Projects
Blog

Wouldn’t it be great if your computer could remind you when your battery is low or fully charged?

Well, the good news is, we can easily build a Desktop Battery Notifier in Python with the given steps.
Let’s walk through how it works.

Build a Desktop Battery Notifier in Python (Beginner Friendly Project)

How Does This Battery Notifier Work?

This small Python script checks your laptop’s battery level and shows a pop-up notification based on certain conditions. It tells you:

  • When your battery is low.
  • When it’s fully charged.
  • When it’s charging but not yet full.
  • When it’s time to unplug the charger for better battery life.

What Do We Need to build this Desktop Battery Notifier?

To build this project, we use two Python libraries:

  • <em><strong>plyer</strong></em>: It shows desktop notifications.
  • <strong><em>psutil</em></strong>: It helps get battery information like percentage and charging status.

You can install both using pip if they are not already available.

Main Logic Behind the Notifier

The logic is quite easy to understand. The script runs and checks two things:

  1. Battery percentage
  2. Whether the charger is plugged in or not

Then, depending on these two factors, it shows different messages.
For example:

  • If the charger is plugged in and the battery is 100%, it notifies you to unplug.
  • If the charger is plugged in and battery is below 80%, it reminds you to charge more.
  • If the charger is not plugged in and the battery is below 20%, it alerts you to plug in.
  • If battery is somewhere around 50%, it gives a general battery update.

When Will You See Notifications?

You’ll get notifications in these situations:

  1. Charging and battery is full
  2. Charging and battery is below 80%
  3. Not charging and battery is low
  4. Not charging and battery is okay
  5. Not charging and battery is full

Each of these cases shows a clear pop-up message on your desktop screen.

Why Is This Useful?

There are many reasons why this battery notifier script is useful:

  1. Avoid overcharging your laptop battery.
  2. Helps maintain better battery life.
  3. You don’t need to keep checking the battery status manually.
  4. Perfect for students, professionals, and coders who often forget to monitor battery.
# Importing required libraries
from plyer import notification 
import psutil

# Get battery status
battery_status = psutil.sensors_battery()
is_charging = battery_status.power_plugged

# Main logic
if __name__ == "__main__":
    charge_percent = battery_status.percent
    
    if is_charging:
        if charge_percent <= 80:
            notification.notify(
                title = "Charging Advice",
                message = "To keep battery healthy, unplug after 80%.",
                timeout = 2
            )
        elif charge_percent == 100:
            notification.notify(
                title = "Battery Full",
                message = "Unplug now. Battery is at 100%.",
                timeout = 2
            )
        else:
            notification.notify(
                title = "Charging Status",
                message = "Battery charging above 80%. Consider unplugging.",
                timeout = 2
            )
    else:
        if charge_percent <= 20:
            notification.notify(
                title = "Low Battery Alert",
                message = "Battery low! Plug in your device.",
                timeout = 2
            )
        elif charge_percent <= 50:
            notification.notify(
                title = "Battery Check",
                message = f"Battery is at {charge_percent}%.",
                timeout = 2
            )
        elif charge_percent == 100:
            notification.notify(
                title = "Battery Full",
                message = "Battery is fully charged.",
                timeout = 2
            )
        else:
            notification.notify(
                title = "Battery Update",
                message = f"Battery level: {charge_percent}%",
                timeout = 2
            )

Final Words

Creating a desktop battery notifier in Python is a super fun and helpful project — especially for beginners. It doesn’t need any GUI or heavy setup. Just install the libraries, write a few lines of code, and you’re good to go.

It’s small, but it solves a real problem.

Post navigation

❮ Previous Post: Build a Simple Music Player in Python Using Tkinter and Pygame

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • About Us
  • Contact Us
  • Privacy Policy
  • Disclaimer

Copyright © 2025 codehelping.com.

Theme: Oceanly by ScriptsTown

Social Chat is free, download and try it now here!