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
A GUI calculator made with tkinter module in python

GUI-Calculator A GUI calculator made with tkinter module in python How to setup the calculator If pygame is not installed, go to terminal and do pip i

Eric Jing 0 Aug 25, 2021
Custom GUI for your Blender add-ons using Dear ImGui

Dear Imgui for Blender Use the infamous Dear ImGui library directly in your Blender scripts! This means custom GUI drawing in your operators: Normally

Elie Michel 83 Dec 25, 2022
LyricsGenerator - A simple GUI made using Python(Tkinter) for generating song lyrics

Lyrics Generator Reference :- https://www.geeksforgeeks.org/create-a-gui-to-extr

Somya Ranjan Sahu 3 Mar 25, 2022
GUI Pancakeswap 2 and Uniswap 3 SNIPER BOT 🥇 🏆 🥇

GUI Pancakeswap V2 and Uniswap V3 trading client (and bot) MOST ADVANCE TRADING BOT SUPPORT WINDOWS LINUX MAC (BUY TOKEN ON LAUNCH)

HYDRA 16 Dec 21, 2021
Gmail account using brute force attack

Programmed in Python | PySimpleGUI Gmail Hack Python script with PySimpleGUI for hack gmail account using brute force attack If you like it give it

Adrijan 127 Dec 30, 2022
Software com funçoes de A a Z feito no Python

Introdução Iniciante em programação Python, decidi criar um programa com diversas ferramentas de A a Z. Funções Ferramenta de Gerenciamento e Manutenç

João Pedro 1 Jan 26, 2022
This a pythonTkinter GUI with sqlite3 Project.

FootballGym_MIS This a pythonTkinter GUI with sqlite3 Project. This software is useful if you want to enjoy running a gym. It helps you know which tea

Hikmatullah Mohammadi 2 Jun 19, 2022
Rich.tui is a TUI (Text User Interface) framework for Python using Rich as a renderer.

rich.tui Rich.tui is a TUI (Text User Interface) framework for Python using Rich as a renderer. The end goal is to be able to rapidly create rich term

Will McGugan 17.1k Jan 04, 2023
TkArt - A repository created to explore geometry and art creation using TkInter

tkArt A repository created to explore geometry and art creation using TkInter, a

Jayant Sogikar 18 Oct 01, 2022
GlobalProtectGUI is a simple tray app to connect, disconnect and monitor globalprotect VPN connection.

Simple GlobalProtectGUI GlobalProtectGUI is simple tray app to connect, disconnect and monitor globalprotect VPN connection. Installation Required bef

Aleksandar Dostic 11 Oct 07, 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
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
Advanced GUI Discord Account Nuker that is easy to use, with many features.

AccountNukeV3 Showcase Youtube: Features: Remove all friends Block all friends Leave all servers Mass create servers Close all dms Mass dm Fuck Settin

Lodi#0001 24 May 22, 2022
Key Cast - Cast your key presses and mouse clicks on the screen, while casting your favorite application on the screen. Better than the rest.

Key Cast Screen cast your keyboard and mouse clicks in style Project Homepage » View Demo · Report Bug · Request Feature Table of Contents Introductio

Mehul Singh Teya 13 Dec 23, 2022
This is the new and improved Plex Automatic Pre-roll script with a GUI

Rollarr This is the new and improved Automatic Pre-roll script with a GUI for Plex now called Rollarr! It should be stable but if you find a bug pleas

164 Nov 04, 2022
A GUI frontend developed in Python3 for simple admin tasks on MySQL-Server running on the localhost

A GUI frontend developed in Python3 for simple admin tasks on MySQL-Server running on the localhost. Developed for my CS School Project.

1 May 29, 2022
build GUIs from python functions, using magic.

magicgui: build GUIs from functions, using magic. 📖 Docs Installation magicgui uses qtpy to support both pyside2 and pyqt5 backends. However, you mus

napari 0 Nov 11, 2022
A GUI Based Figlet Maker

Figlet Creation Create Figlets easily using this application created using PySimpleGUI. Installation Old-school Straight Pip pip install psg-figlet pi

PySimpleGUI 8 Jan 06, 2023
Input an antlr grammar and file for python to test it out

py-antlr-input Input an ANTLR grammar and test file for python to render a parser tree of the file. This program will make use of the grun command tha

Oscar Juárez 0 Aug 10, 2021
A little Python library for making simple Electron-like HTML/JS GUI apps

Eel Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries. Ee

Chris Knott 5.4k Jan 07, 2023