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
Desktop application for Windows/macOS users to rotate through custom, preset, and searched-for collections of backgrounds with scheduling and additional settings

Background Revolution (In Development, Alpha Release) What? This will be an application for users to customize their windows backgrounds by uploading

Daniel Agapov 1 Nov 2, 2021
Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS

Kivy Innovative user interfaces made easy. Kivy is an open source, cross-platform Python framework for the development of applications that make use o

Kivy 15.4k Jan 7, 2023
Cross-platform BrowserViews for the desktop.

Webview We use wxPython Phoenix to provide webviews. It's cross platform between Windows and macOS primarily, Linux versions require extra setup. Appl

null 1 Feb 12, 2022
A cute running cat animation on your Windows/macOS taskbar.

RunCat by PySide6 A cute running cat animation on your Windows/macOS taskbar. Tags PyQt PySide RunCat Demo You only have to run the RunCat.exe. Run pi

見える 10 Sep 19, 2022
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
A small pomodoro GUI for Windows/Linux created in Python with PyQt5.

Pomodoro A small pomodoro GUI for Windows/Linux created with PyQt5. Features The "Timer" tab allows you to set your desired work and rest times aswell

Burak Martin 81 Dec 28, 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

Bimba Shrestha 283 Nov 30, 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

null 283 Nov 30, 2022
Windows & Linux GUI application to use a Satodime (satodime.io)

Satodime-Tool Licence: LGPL v3 Author: Toporin Language: Python (>= 3.6) Homepage: https://github.com/Toporin/Satodime-Tool Introduction What is Satod

null 4 Dec 16, 2022
A simple fusee-launcher frontend for macOS

A simple fusee-launcher frontend for macOS (Universal). Supports macOS >= 10.9. It has libusb statically linked, so you don't need to install anything

rob 25 Dec 19, 2022
pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.

pyglet pyglet is a cross-platform windowing and multimedia library for Python, intended for developing games and other visually rich applications. It

null 1.3k Jan 1, 2023
A simple desktop news application written using python created using PyQt5

News-Application---Python This is a news application created using PyQt5. News is fetched through API from newsapi.org. Available top headlines from c

Sritiman Adak 1 Nov 14, 2021
Kivy is an open source Python framework for creating cross-platform multi-touch mobile applications with Natural User Interface.

Kivy is an open source Python framework for creating cross-platform multi-touch mobile applications with Natural User Interface.

Grace Ugochi Nneji 3 Feb 15, 2022
HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities.

HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities. Looking for Artwork This project is looking for an Icon an

null 8 Dec 3, 2022
A desktop application developed in Python with PyQt5 to predict demand and help monitor and schedule brewing processes for Barnaby's Brewhouse.

brewhouse-management A desktop application developed in Python with PyQt5 to predict demand and help monitor and schedule brewing processes for Barnab

Isaac Cheng 2 Jul 9, 2022
Learn to build a Python Desktop GUI app using pywebview, Python, JavaScript, HTML, & CSS.

Python Desktop App Learn how to make a desktop GUI application using Python, JavaScript, HTML, & CSS all thanks to pywebview. pywebview is essentially

Coding For Entrepreneurs 55 Jan 5, 2023
Write desktop and web apps in pure Python

Flexx Want to stay up-to-date about (changes to) Flexx? Subscribe to the NEWS issue. Introduction Flexx is a pure Python toolkit for creating graphica

flexxui 3.1k Dec 29, 2022
Write desktop and web apps in pure Python

Flexx Want to stay up-to-date about (changes to) Flexx? Subscribe to the NEWS issue. Introduction Flexx is a pure Python toolkit for creating graphica

flexxui 3.1k Jan 8, 2023