Skip to content

codehelping.com

Best Platform to learn AI & Coding

  • Home
  • Projects
  • Notes
  • Blog
  • Contact Us

Build a Desktop Battery Notifier in Python | CodeHelping Projects

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

Let’s build a project that tells your laptop or computer battery is how much charged i.e, a Desktop Battery Notifier in Python using psutil and plyer library notification.
This project is best to add in your resume if your are a fresher or you want internships.

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

How Does This Desktop Battery Notifier in Python 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: Battery percentage and 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 may look small project but can add a great impression for a fresher project. For more such small and very good projects in python visit here.

Post navigation

❮ Previous Post: Build a Simple Music Player in Python Using Tkinter and Pygame
Next Post: How to Build Your own AI Model Step by Step | CodeHelping ❯

2 thoughts on “Build a Desktop Battery Notifier in Python | CodeHelping Projects”

  1. Kyle Kertzmann says:
    August 18, 2025 at 11:58 pm

    Hello i think that i saw you visited my weblog so i came to Return the favore Im trying to find things to improve my web siteI suppose its ok to use some of your ideas

    Reply
    1. Omkar Pathak says:
      August 21, 2025 at 7:51 pm

      what is name of your blog?

      Reply

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!