How to send Desktop Notifications with Python

Just because we can

Ecnivs
2 min readNov 12, 2022

Introduction

In this article, I will demonstrate how to create a Simple Desktop Notifier using python. A desktop notifier is a program that produces a desktop notification in the form of a popup. In our case, we will use the plyer module.

Modules:

  1. 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

Approach:

Step 1) Import the notification class from plyer module.

from plyer import notification

Step 2) Call the notify method of this class.

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

Parameters:

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

Below is the implementation.

from plyer import notification

if __name__=="__main__":

notification.notify(
title = "ALERT!!!",
message = "Take a break! It has been an hour!",
timeout = 10
)
Output

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Ecnivs
Ecnivs

Written by Ecnivs

Speaks fluent code and sarcasm.

No responses yet

Write a response