Skip to content
Related Articles
Open in App
Not now

Related Articles

Create Battery Notifier for Laptop using Python

Improve Article
Save Article
  • Last Updated : 09 Mar, 2021
Improve Article
Save Article

Laptop or P.C battery charging is always a tension. We often forget to charge our laptop and seem to check the battery. This article demonstrates how to create a simple Battery Notifier application using Python. A battery notifier is a simple application that produces a notification message in the form of a pop-up message on the desktop.  With Python, we can do so with the help of psutil library and plyer library.

Modules needed

pip install psutil
  • plyer: Plyer module is used to access the features of the hardware. This module does not comes built-in with Python. We need to install it externally. To install this module type the below command in the terminal.
pip install plyer


Step 1) Import the notification class from the plyer module

from plyer import notification

Step 2) After that you just need to call the notify method of this class.

Syntax: notify(title=”, message=”, app_name=”, app_icon=”, timeout=10, ticker=”, toast=False)


  • title (str) – Title of the notification
  • message (str) – Message of the notification
  • app_name (str) – Name of the app launching this notification
  • app_icon (str) – Icon to be displayed along with the message
  • timeout (int) – time to display the message for, defaults to 10
  • ticker (str) – text to display on status bar as the notification arrives
  • toast (bool) – simple Android message instead of full notification

Step 3) Add the sleep function to show that notification again.

Below is the implementation.


import psutil
from plyer import notification
import time
# from psutil we will import the
# sensors_battery class and with
# that we have the battery remaining
    battery = psutil.sensors_battery()
    percent = battery.percent
        title="Battery Percentage",
        message=str(percent)+"% Battery remaining",
    # after every 60 mins it will show the
    # battery percentage




Note: The time in the sleep function has been reduced to record the output window.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!