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
Py3editor - A text editor written in Python and Tkinter

Py3Editor My text editor written in Python and Tkinter! Contains a basic set of

JaydenDev 1 Mar 05, 2022
Python script with tkinter that allows you to open a local chat room

Server_chat Python script with tkinter that allows you to open a local chat room To begn you'll have to start the server side script and run it. You w

2 Feb 11, 2022
Transparent & click through tkinter window. WINDOWS ONLY

REQUIREMENTS: WINDOWS ONLY pip install pywin32 NOTES: Will not work on top of a fullscreen application, if you are using this to draw on top of a gam

francis 2 Nov 04, 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
This is the new and improved Plex Automatic Pre-roll script with a GUI

Plex-Automatic-Pre-roll-GUI This is the new and improved Plex Automatic Pre-roll script with a GUI! It should be stable but if you find a bug please l

164 Nov 04, 2022
A Python native, OS native GUI toolkit.

Toga A Python native, OS native GUI toolkit. Prerequisites Minimum requirements Toga requires Python 3. Python 2 is not supported. If you're on macOS,

BeeWare 3.3k Dec 31, 2022
Small Python scripts to take screenshot from a KaiOS/FFOS device and to mirror the screen of your phone.

This version of kaiscr is written by tkinter and can run in windows(use kailive-tk.py). "kailive-tk-speed.py" is speed optimization version. The sourc

openGiraffes Group 2 Mar 02, 2022
This was my test project when i started to learn Python Tkinter. Its the simplest interface possible.

Rock-Paper-Scissors-Game- Project Description: This was my test project when i started to learn Python Tkinter. Its the simplest interface possible. R

Hassan Shahzad 2 Jan 17, 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
Browser - A GTK browser trying to follow the GNOME Human Interface Guidelines.

A simple GTK browser trying to follow the GNOME Human Interface Guidelines.

Cleo Menezes 12 Nov 26, 2022
WhirlEdit, an excellent {code} editor

HELP! If you're experienced, I want you to make an executable for your platform (windows/mac/linux) and help me.. For more info get in touch at whirlp

whmsft 10 Aug 18, 2022
CBMPy Metadraft: a flexible and extensible genome-scale model reconstruction tool

CBMPy Metadraft: a flexible and extensible, GUI-based genome-scale model reconstruction tool that supports multiple Systems Biology standards.

Systems Biology Lab, Vrije Universiteit Amsterdam 1 Mar 14, 2022
GUI to enable user selection of measurement and station in kHTConnector module.

kHTGui GUI to enable user selection of measurement and station in kHTConnector module. Helper tool for PowerBI users If you're planning to import data

kk 1 Jan 26, 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
Tkinter Designer - Create Beautiful Tkinter GUIs by Drag and Drop.

Tkinter Designer is created to speed up and beautify Python GUI Experience. It uses well know design software called Figma. Which makes creating Tkinter GUI in Python a piece of cake.

Parth Jadhav 5.2k Jan 09, 2023
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
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
A simple todo GUI applicaiton

simple_todo_gui A simple todo GUI applicaiton To create an .exe file, run 'Python setup.py build' after installing PyQt5 and cx_Freeze with pip. Then

Dhammike Piyumal 2 Nov 11, 2021
Edifice: a declarative GUI library for Python

Edifice is a Python library for building reactive UI, inspired by modern Javascript libraries such as React.

David Ding 193 Dec 11, 2022
PyQt QGraphicsView with selection box. User can move vertical border of the box horizontally.

pyqt-horizontal-selection-square-graphics-view PyQt QGraphicsView with selection box. User can move vertical border of the box horizontally. Requireme

Jung Gyu Yoon 3 Nov 07, 2022