A simple Python Module for sending cross-platform desktop notifications on Windows, macOS and Linux

Overview

notify.py

Cross platform desktop notifications for Python scripts and applications.


Docs

You can read the docs on this Git's Wiki, or here

Supported Platforms.

  • Windows 10/11
  • macOS 10 >=10.10
  • Linux (libnotify)

No dependencies are required other than loguru & jeepney (Only for linux/DBUS).


Install

pip install notify-py

Usage

Send Simple Notification

from notifypy import Notify

notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
notification.send()

Send Notification With Icon

from notifypy import Notify

notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
notification.icon = "path/to/icon.png"

notification.send()

Send Notification With Sound

from notifypy import Notify

notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
notification.audio = "path/to/audio/file.wav"

notification.send()

Sending Notifications without blocking

from notifypy import Notify

notification = Notify()
notification.send(block=False)

Sending with Default Notification Titles/Messages/Icons

from notifypy import Notify

notification = Notify(
  default_notification_title="Function Message",
  default_application_name="Great Application",
  default_notification_icon="path/to/icon.png",
  default_notification_audio="path/to/sound.wav"
)

def your_function():
  # stuff happening here.
  notification.message = "Function Result"
  notification.send()

CLI

A CLI is available when you install notify-py

notify-py --title --message --applicationName --iconPath --soundPath

You may need to add python3 -m to the beginning.


Important Caveats

  • As it stands (May 18, 2020), this is simply a notification service. There is no support for embedding custom actions (buttons, dialogs) regardless of platform. Other then telling you if the shell command was sent, there is also no confirmation on user action on the notification.

  • macOS does not support custom icons on the fly.. You will need to bundle a customized version of the notifier embedded with your custom icon.


Windows Specific.

  • No support for balloon tips (pre Win10).. This will be changed in the future.

Contributors


Inspiration and Special Thanks


Contributing

Contributions are welcome!

Please base your changes on the latest development branch and open a PR to that branch. PR will not be accepted to the master branch. Tests are ran against all platforms.

Setting Up Environment

  • Install Poetry
    • poetry install
  • Add patches/new features/bug fiexes
  • Run tests
    • poetry run pytest tests/*
  • Run lints
    • poetry run pylint --errors-only notifypy/
  • Run Black Formatting
    • poetry run black notifypy
  • Open PR to dev branch.
  • Add your name to contributors list if you wish!
Comments
  • Improvements | notify-send | Urgerncy | Which | BSD

    Improvements | notify-send | Urgerncy | Which | BSD

    https://github.com/ms7m/notify-py/blob/f748189a2e8b4b147fcbf1acb6912c944d687671/notifypy/os_notifiers/linux.py#L33

    • Added: notification urgency (low, normal, critical) for notify-send
    • Fixed: notify-send, now is being used as the first choice if installed
    • Fixed: OSs like BSD now default under the linux-behavioural category
    • Fixed: issue under windows with extra kwargs that resulted in error
    • Removed: linux_fallback_libnotify, no more need for it
    • Replaced: functions with the in-built shutil.which function

    PS. Tried not to be messy with the code and respect your overall structural patterns. It has been tested and works fine both on linux and on windows (+the in-built shutil.which function works with BSD too)

    opened by GiorgosXou 10
  • Notification Sound not working on Linux

    Notification Sound not working on Linux

    I am using parrot os. I have use the library for my project and everything works great except for the sound. At first it used .mp3 and it threw an error so i changed to .wav file and now i am not having errors but still when the notification comes, there is no sound.

    bug Linux 
    opened by MusheAbdulHakim 10
  • Powershell prompt will appear if audio is passed.

    Powershell prompt will appear if audio is passed.

    When I try to make an exe of my python program with pyinstaller if the notification has audio an powershell prompt pops up. The paremeters I used were: --onefile --noconsole

    bug Windows Pyinstaller Related 
    opened by Zac8668 8
  • Supress Powershell popping up in pyinstaller .exe

    Supress Powershell popping up in pyinstaller .exe

    Hi, I noticed a bug of notify-py in combination with PyInstaller on Windows (10): If a program using notify-py is compiled to an .exe with the --windowed flag, the powershell windows pop's up for second when a notification is shown.

    This commit should fix it.

    To reproduce:

    1. Deps:
      pip install pyinstaller notify-py
      
    2. Create test.py:
      from notifypy import Notify
      notification = Notify()
      notification.send(block=False)
      
    3. Compile to .exe:
      pyinstaller --windowed test.py
      
    4. Run ./dist/test/test.exe

    Result: powershell

    opened by dynobo 2
  • Suppress logging output by default

    Suppress logging output by default

    When I am sending notification I get bunch of logging output into the terminal. Since this is a library people might not be really interested in this logging by default. For example, I am using it in CLI application and there it is very distracting and not required.

    Can you please by default turn it off? Maybe it could be turned on with a flag in options of the constructor? Or environmental variable? I logging will be used only in debugging scenario.

    opened by AuHau 2
  • Unable to find required afplay - binaries not released?

    Unable to find required afplay - binaries not released?

    First of all thanks for putting this together!

    I wanted to use it for https://github.com/AuHau/toggl-cli but ran into problem where when I want to show notification I get:

    Traceback (most recent call last):
    ...
      File "/Users/adam/Projects/me/toggl-cli/toggl/cli/commands.py", line 396, in notify
        notification = Notify()
      File "/Users/adam/Projects/me/toggl-cli/.direnv/python-3.8.1/lib/python3.8/site-packages/notifypy/notify.py", line 30, in __init__
        self._notifier = self._notifier_detect()
      File "/Users/adam/Projects/me/toggl-cli/.direnv/python-3.8.1/lib/python3.8/site-packages/notifypy/os_notifiers/macos.py", line 15, in __init__
        call_find_notificator = self._find_bundled_notificator()
      File "/Users/adam/Projects/me/toggl-cli/.direnv/python-3.8.1/lib/python3.8/site-packages/notifypy/os_notifiers/macos.py", line 40, in _find_bundled_notificator
        raise BinaryNotFound("afplay")
    notifypy.exceptions.BinaryNotFound: Unable to find required afplay. Please check if it's installed.
    

    I inspected the package and I see that it is still released with the snoretoast.exe and that the MacOs binary is not included. It seems bit weird but maybe you released old version?

    opened by AuHau 2
  • Install notifypy CLI script with poetry as well

    Install notifypy CLI script with poetry as well

    It looks like the switch from setuptools to poetry broke the CLI script install, as that was only specified in setup.py. This change adds the appropriate [tool.poetry.scripts] entry to pyproject.toml so that will happen again:

    ~/code/notify-py (wisnij/20230102-poetry-install-cli=) $ pip install . -v
    Using pip 22.3.1 from /usr/lib/python3/dist-packages/pip (python 3.10)
    [...]
    Successfully built notify-py
    Installing collected packages: notify-py
      changing mode of /home/wisnij/.local/bin/notifypy to 755
    Successfully installed notify-py-0.3.38
    
    opened by wisnij 1
  • update loguru to 0.6.0

    update loguru to 0.6.0

    It has been some time since loguru's new release. There is not any breaking changes. It is better to update the version restriction on https://github.com/ms7m/notify-py/blob/c6f30e0784eb18d3b4424ede706719a5fd7cf7b9/pyproject.toml#L16

    New Version 
    opened by jnoortheen 1
  • Inherit correct Exception class

    Inherit correct Exception class

    From Python documentation:

    exception BaseException The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use Exception).

    opened by mingmingrr 1
  • chore(deps-dev): bump py from 1.9.0 to 1.10.0 in /.removal

    chore(deps-dev): bump py from 1.9.0 to 1.10.0 in /.removal

    Bumps py from 1.9.0 to 1.10.0.

    Changelog

    Sourced from py's changelog.

    1.10.0 (2020-12-12)

    • Fix a regular expression DoS vulnerability in the py.path.svnwc SVN blame functionality (CVE-2020-29651)
    • Update vendored apipkg: 1.4 => 1.5
    • Update vendored iniconfig: 1.0.0 => 1.1.1
    Commits
    • e5ff378 Update CHANGELOG for 1.10.0
    • 94cf44f Update vendored libs
    • 5e8ded5 testing: comment out an assert which fails on Python 3.9 for now
    • afdffcc Rename HOWTORELEASE.rst to RELEASING.rst
    • 2de53a6 Merge pull request #266 from nicoddemus/gh-actions
    • fa1b32e Merge pull request #264 from hugovk/patch-2
    • 887d6b8 Skip test_samefile_symlink on pypy3 on Windows
    • e94e670 Fix test_comments() in test_source
    • fef9a32 Adapt test
    • 4a694b0 Add GitHub Actions badge to README
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump py from 1.9.0 to 1.10.0

    Bump py from 1.9.0 to 1.10.0

    Bumps py from 1.9.0 to 1.10.0.

    Changelog

    Sourced from py's changelog.

    1.10.0 (2020-12-12)

    • Fix a regular expression DoS vulnerability in the py.path.svnwc SVN blame functionality (CVE-2020-29651)
    • Update vendored apipkg: 1.4 => 1.5
    • Update vendored iniconfig: 1.0.0 => 1.1.1
    Commits
    • e5ff378 Update CHANGELOG for 1.10.0
    • 94cf44f Update vendored libs
    • 5e8ded5 testing: comment out an assert which fails on Python 3.9 for now
    • afdffcc Rename HOWTORELEASE.rst to RELEASING.rst
    • 2de53a6 Merge pull request #266 from nicoddemus/gh-actions
    • fa1b32e Merge pull request #264 from hugovk/patch-2
    • 887d6b8 Skip test_samefile_symlink on pypy3 on Windows
    • e94e670 Fix test_comments() in test_source
    • fef9a32 Adapt test
    • 4a694b0 Add GitHub Actions badge to README
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • WSL support

    WSL support

    Hi! Thank you for this great packages!

    It will be cool to have WSL support.

    One way is to have an ability to send notifications using external tools i.e. wsl-notify-send:

    image

    For community

    ⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

    opened by anki-code 0
  • Release publishing workflow issues

    Release publishing workflow issues

    I'm trying to package this python module for a Linux distro and there are some issues I've noticed with your published packages:

    1. Source releases don't include a copy of the MIT license the MIT license requires you provide a copy of the LICENSE file when you distribute your module
    2. Some releases published on PyPI aren't published on GitHub retrieving the source releases for packaging from GitHub brings lower maintenance overhead and better transparency than retrieving them from PyPI
    3. Release file naming isn't very packager friendly the module is named notify-py, yet the published release file names are notify_py, inconsistencies like this increase the verbosity of the packaging definitions and maintenance overhead
    help wanted Discussion 
    opened by KloudJack 1
  • Unable to re-enable notifications for specific application name.

    Unable to re-enable notifications for specific application name.

    Reference

    https://github.com/dynobo/normcap/issues/87

    Looks like if a user manually "turns off" the notification sent by notify-py. They are unable to "re-enable". Need to find a workaround to allow the user to have the option to re-enable in the Windows Settings..

    Current workaround is to simply change the application_name to something else each time you send a notification or when first initializing the Notify object..

    bug help wanted Windows 
    opened by ms7m 2
Releases(v0.3.39)
Owner
Mustafa
Intern, Software Development (DevOps/Automation/Application Backend).
Mustafa
GUI app to read settings and stats from Cloudflare WARP CLI for Linux, and change some settings

warp-cli-gui GUI app to read settings and stats from Cloudflare WARP CLI for Linux, and change some settings. Description Python program that will int

Danie 6 Nov 01, 2022
A graphical user interface calendar with python

GUI-Calendar A graphical user interface calendar with python In this project I used tkinter module If you dont have tkinter module you can install it

Arone Sadegh 1 Dec 18, 2021
Python Screen Recorder using Python

PY-Screen-Recorder Python Screen Recorder using Python Requirement: pip install cv2 pip install pyautogui pip install numpy How to reach me? You can r

SonLyte 8 Nov 08, 2021
A GUI frontend for the Kamyroll-API using Python and PySide6

Kamyroll-GUI A GUI frontend for the Kamyroll-API using Python and PySide6 Usage When starting the application you will be presented with a list and so

Simon Sawicki 15 Oct 09, 2022
A Minimalistic Backup GUI for your Windows, Mac or Linux

BlobBackup is a minimalistic backup utility for your Windows, Mac or Linux computer. With an excellent engine, extensive storage support, and an easy

283 Nov 30, 2022
Build GUI for your Python program with JavaScript, HTML, and CSS

https://pywebview.flowrl.com pywebview is a lightweight cross-platform wrapper around a webview component that allows to display HTML content in its o

Roman 3.3k Jan 01, 2023
Win32mica: a simple module to add the Mica effect on legacy python windows.

Win32mica (aka PyMica): A simple module to add the Mica effect on legacy python windows The aim of this project is to apply the Mica effect on python

Martí Climent 40 Dec 13, 2022
PyQt5 Sample GUI Program - Python PyQt5 Sample GUI application

Python PyQt5 Sample GUI application Program work like this Designed GUI using De

Dimuth De Zoysa 5 Mar 27, 2022
Criando interfaces gráficas com Python e Qt 6 (PyQt6)

Criando interfaces gráficas com Python e Qt 6 (PyQt6) Qt O Qt é um framework para criação de interfaces gráficas multiplataforma, atualmente ele é des

Renato Cruz 1 Jun 07, 2022
UberGui is a lightweight multi-threaded, webRender UI module for TouchDesigner

UberGui V4 UberGui is a lightweight multi-threaded, webRender UI module for TouchDesigner projects. The aim is to solve the trifecta of challenges bui

LUCAS M MORGAN 48 Nov 20, 2022
Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code.

Mini Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code. The code is written and published as is, so the

Dmitry Karpenko 6 Nov 07, 2022
Make desktop applications using HTML and CSS with python

Neutron Make desktop applications using HTML and CSS with python What is Neutron Neutron will allow developers to design modern applications in python

Ian Baldelli 284 Dec 29, 2022
UI to save and load gnome-shell extension templates.

Gnome Extensions Loader GUI to save and load gnome shell extensions and extension settings. This app makes it easier to share your gnome extensions se

EMRECAN ALTINSOY 2 Nov 25, 2022
A Simple GUI application to organize and store accounts/passwords.

PyssView A Simple GUI application to organize and store accounts/passwords. Install/Run (Linux) Via script This way will install a binary version and

Jefferson Richard Dias 1 Nov 24, 2021
This is a short GUI project to evaluate Pbk solution.

Polubarinova-Kochina-solutions (Standalone GUI executables for Windows and Mac) Oden Institute for Computational Engineering and Sciences / Jackson Sc

Mohammad Afzal Shadab 1 Dec 24, 2022
Tkinter-ATM - Python GUI case made with Tkinter

tkinter-ATM Python GUI case made with Tkinter The task of this case was to creat

2 Jan 13, 2022
MATE Layouts is a small panel layout switching application for the MATE Desktop.

a small panel layout switching application for the MATE Desktop

Wilbur Wetterquarz 6 Oct 14, 2022
Primeira interface (simples) desenvolvida em Python utilizando o PySimpleGUI

Interface-Python Sobre o projeto Primeira interface gráfica (simples) desenvolvida em Python utilizando o PySimpleGUI Interface Gráfica Tecnologias ut

Matheus Maia Alvarez 5 Apr 09, 2022
python+PySimpleGUI+pyserial+threading

GUI_pyserial python+PySimpleGUI+pyserial+threading 功能 1.利用PySimpleGUI制作图形用户界面 2.利用threading实现多线程调用pyserial处理串口通信 模块版本 PySimpleGUI 4.46.0 pyserial 3.5

2 Dec 27, 2022
This program is written in python. It will help you find a valid solution for a sudoku puzzle.

Sudoku-Solver-Using-Tkinter This program is written in python. It will help you find a valid solution for a sudoku puzzle. Requirements: Python3 IDLE

Ankan Mahapatra 3 Oct 02, 2021