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
LittlePythonGUIGuide - This is a short GUI Guide with python

This is a short GUI Guide with python, learning how to use the simple and easy moduel built into python, named tkinter.

1cy50ng3b0b 1 Nov 21, 2021
Weather-API-GUI-Tkinter - A weather tool made using tkinter which works by fetching query city weather using an API

Weather-API-GUI-Tkinter ☁️ ❄️ version- 1️⃣ . 0️⃣ . 0️⃣ This repo contains a weat

SasiVatsal 4 Jul 08, 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
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 GUI for designing Python GUI's for PySimpleGUI.

SimpleGUIBuilder A GUI for designing Python GUI's for PySimpleGUI. Installation There is none :) just download the file from a release and run it. Don

Miguel Martins 65 Dec 22, 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
Uma interfáce de usuário relativamente simples em pyqt5 + escolha de dispositivos

Interface para Scrcpy Uma interfáce de usuário relativamente simples em pyqt5 para sistemas UNIX Requerimentos: Python3 PyQt5 adb scrcpy Você pode ins

hayukimori 10 Dec 16, 2022
OpenPort scanner GUI tool (CNMAP)

CNMAP-GUI- OpenPort scanner GUI tool (CNMAP) as you know it is the advanced tool to find open port, firewalls and we also added here heartbleed scanni

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

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 P

Mustafa 178 Dec 26, 2022
Python code examples on how to create several applications using Dear PyGui.

Python code examples on how to create several applications using Dear PyGui. Includes building and editing a table, as well as visualizing sorting algorithms in a plot.

Alexander H. 7 Sep 15, 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
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
Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies

(This library is available under a free and permissive license however, if you Enjoy Dear PyGui please consider becoming a Sponsor) Dear PyGui is a si

Jonathan Hoffstadt 9.4k Jan 07, 2023
A tf publisher gui tool for ROS, which publish /tf_static message. The software is based on PyQt5.

tf_publisher_gui for ROS Introduction How to use cd catkin_ws/src git clone https://github.com/yinwu33/tf_publisher_gui.git cd catkin_ws catkin_make s

yinwu33 7 Dec 28, 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
FPKG Maker GUI - A user friendly User Interface for fPKG Tools for PS4

Know Issues being worked on Please place this application on the root of a drive

26 Nov 27, 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
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
System Tray Icon for PySimpleGUI (the tkinter version). Adds a system tray icon by using pystray and PIL

psgtray Add a System Tray Icon to your tkinter port of PySimpleGUI. Installation via pip Installation is via pip: python -m pip install psgtray or if

PySimpleGUI 38 Dec 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