Code Monkey home page Code Monkey logo

desktop-notifier's People

Contributors

dependabot[bot] avatar iamkroot avatar ilkergzlkkr avatar matkoniecz avatar samschott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

desktop-notifier's Issues

Button on_pressed callback does not get called for first button

  • Desktop Notifier version: 3.3.4
  • Python version: 3.10.2
  • Operating System: Fedora 35

Description

The on_pressed callback is never called for the first button added to a notification. This is because the action_key is '0' in this case, which evaluates to False after converting it to an int, so the elif button_number condition on line 203 of desktop_notifier.dbus fails.

What I Did

python3 examples/eventloop.py

Click the Mark as read button; notice that Marked as read is never printed to the console.

weak docs and tutorials and custom sound !

  • Desktop Notifier version:3.4.0
  • Python version:3.10
  • Operating System:Linux Debian distros , Arch , MS Win 8.1 & 10 & 11, Mac OS 10 & 12

Description

Hi, thanks for your hard workings.

in my office we use this library to create 2 necessary softwares one: to alert us extracting price list has done and the other: urgent sell has been issued.

for our developers, lack of docs and tutorials are pain. To be honest ,apologize my French!, a saw in our asses! not gonna lie!!

and for for sounds:
with this in mind this library play a vital role in my department having a same sound for 2 different software is not good.better to be able to use custome sounds

p.s. : all OS above are using in my office!

[macOS] Segfault when initialising notification centre outside of framework or app bundle

Describe the bug

I used to be able to run Maestral on macOS, but not anymore, and I wonder whether it is related to macOS Big Sur upgrade (or perhaps another upgrade?).

To Reproduce

  1. Install miniconda.
  2. Create a Python environment: conda create -n dropbox python=3.8, then activate it.
  3. Start maestral with maestral start.

At this point, I got this error:

Starting Maestral...        [FAILED]
Please check logs for more information.

Expected behaviour
Maestral daemon should run.

System:

  • Maestral version: 1.4.4
  • Python version: 3.8
  • OS: [e.g. Ubuntu] macOS
  • Desktop environment: [e.g. Gnome 3.32] macOS
  • PyQt version (for Linux GUI): N/A

Additional context

When I show the logs with maestral logs show, I see the following:

2021-06-20 12:08:29 daemon ERROR: Could not communicate with daemon
Traceback (most recent call last):
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 278, in connect_and_handshake
    sock = socketutil.create_socket(connect=connect_location,
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/socketutil.py", line 283, in create_socket
    sock.connect(connect)
FileNotFoundError: [Errno 2] No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 617, in start_maestral_daemon_process
    wait_for_startup(config_name, timeout)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 407, in wait_for_startup
    raise exc
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 403, in wait_for_startup
    maestral_daemon._pyroBind()
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 182, in _pyroBind
    return self.__pyroCreateConnection(True)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 342, in __pyroCreateConnection
    connect_and_handshake(conn)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 304, in connect_and_handshake
    raise errors.CommunicationError(err) from x
Pyro5.errors.CommunicationError: cannot connect to /Users/rafidka/Library/Application Support/maestral/maestral.sock: [Errno 2] No such file or directory
2021-06-20 12:08:29 daemon ERROR: Daemon stopped with return code -6
2021-06-20 12:12:02 daemon ERROR: Could not communicate with daemon
Traceback (most recent call last):
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 278, in connect_and_handshake
    sock = socketutil.create_socket(connect=connect_location,
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/socketutil.py", line 283, in create_socket
    sock.connect(connect)
FileNotFoundError: [Errno 2] No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 617, in start_maestral_daemon_process
    wait_for_startup(config_name, timeout)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 407, in wait_for_startup
    raise exc
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 403, in wait_for_startup
    maestral_daemon._pyroBind()
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 182, in _pyroBind
    return self.__pyroCreateConnection(True)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 342, in __pyroCreateConnection
    connect_and_handshake(conn)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 304, in connect_and_handshake
    raise errors.CommunicationError(err) from x
Pyro5.errors.CommunicationError: cannot connect to /Users/rafidka/Library/Application Support/maestral/maestral.sock: [Errno 2] No such file or directory
2021-06-20 12:12:02 daemon ERROR: Daemon stopped with return code -6
2021-06-20 12:29:30 daemon ERROR: Could not communicate with daemon
Traceback (most recent call last):
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 278, in connect_and_handshake
    sock = socketutil.create_socket(connect=connect_location,
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/socketutil.py", line 283, in create_socket
    sock.connect(connect)
FileNotFoundError: [Errno 2] No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 617, in start_maestral_daemon_process
    wait_for_startup(config_name, timeout)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 407, in wait_for_startup
    raise exc
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/maestral/daemon.py", line 403, in wait_for_startup
    maestral_daemon._pyroBind()
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 182, in _pyroBind
    return self.__pyroCreateConnection(True)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 342, in __pyroCreateConnection
    connect_and_handshake(conn)
  File "/Users/rafidka/miniconda3/envs/dropbox/lib/python3.8/site-packages/Pyro5/client.py", line 304, in connect_and_handshake
    raise errors.CommunicationError(err) from x
Pyro5.errors.CommunicationError: cannot connect to /Users/rafidka/Library/Application Support/maestral/maestral.sock: [Errno 2] No such file or directory
2021-06-20 12:29:30 daemon ERROR: Daemon stopped with return code -6

I tried to manually execute the daemon from Python and this is what I see:

>>> import maestral.daemon
>>> maestral.daemon.start_maestral_daemon('maestral', True)
2021-06-20 12:26:11.732 python[43518:841675] *** Assertion failure in +[UNUserNotificationCenter currentNotificationCenter], UNUserNotificationCenter.m:54
2021-06-20 12:26:11.732 python[43518:841675] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleProxyForCurrentProcess is nil: mainBundle.bundleURL file:///Users/rafidka/miniconda3/envs/dropbox/bin/'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff2079887b __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff204d0d92 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff207c19e2 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff2157d512 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   UserNotifications                   0x00007fff2a691540 __53+[UNUserNotificationCenter currentNotificationCenter]_block_invoke + 985
	5   libdispatch.dylib                   0x00007fff2047b806 _dispatch_client_callout + 8
	6   libdispatch.dylib                   0x00007fff2047c98c _dispatch_once_callout + 20
	7   UserNotifications                   0x00007fff2a691165 +[UNUserNotificationCenter currentNotificationCenter] + 101
	8   libffi.7.dylib                      0x000000010fb45ead ffi_call_unix64 + 85
	9   ???                                 0x00007ffee0e07210 0x0 + 140732671226384
)
libc++abi: terminating with uncaught exception of type NSException
[1]    43518 abort      python

[Feature Request] Support for timeouts

At least on Linux, the notification spec supports specifying the timeout for every notification. It would be great if this option is exposed to the top-level API as timeout: int = -1 (-1 means OS default).

Bonus

For other OSes, maybe this can be implemented by spawning an async Timer task that will clear the notif after expiration.

PS: Thanks for making this project. It is extremely useful to have a singular and full-featured interface for cross-platform notifications! :)

Callbacks on Windows

  • Desktop Notifier version: 3.5.6
  • Python version: 3.8
  • Operating System: Windows 3.10

Description

I am trying the callback mechanism using the Et tu brutus example on Windows. There is no feedback after responding to the notification, I checked if the terminal was hanging by hitting enter a few times, but no, the callbacks don't seem to be executed.

Any special things I forgot for Windows? It works on my mac...

This script saved as send.py

import asyncio
from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField

notifier = DesktopNotifier()

async def main():
  await notifier.send(
      title="Julius Caesar",
      message="Et tu, Brute?",
      urgency=Urgency.Critical,
      buttons=[
        Button(
          title="Mark as read",
          on_pressed=lambda: print("Marked as read")),
      ],
      reply_field=ReplyField(
        title="Reply",
        button_title="Send",
        on_replied=lambda text: print("Brutus replied:", text),
      ),
      on_clicked=lambda: print("Notification clicked"),
      on_dismissed=lambda: print("Notification dismissed"),
      sound=True,
  )
  

loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()

Executed
python send.py

Then entered answer in the textbox and clicked send

Screen Recording 2024-03-15 at 11 07 55

Needing workaround for subprocess in signed application bundle

I'm trying to use this library from a PyInstaller-built binary aw-notify running as a subprocess in my application.

The whole thing is correctly signed with PyInstaller (see spec file). The CFBundleExecutable is aw-qt, which manages aw-notify as a subprocess.

However, the subprocess doesn't seem to get NSBundle.mainBundle.bundleIdentifier set. Which fails the check at:

https://github.com/samschott/desktop-notifier/blob/233d8c8981945c64fb92df2dbade908624896b7b/src/desktop_notifier/macos_support.py#L55C11-L55C11

@samschott wrote here:

The alternative would be to try and fake a valid bundle identifier at runtime. Some other packages do this but its a nasty hack and will prevent any apps using it from being accepted in the App store.

I am now assuming that I would need some kind of workaround like that, and that things would probably work if it wasn't for this NSBundle check (hopeful/wishful thinking).

Since the testing process is rather lengthy for me, given how I have to wait for CI to sign etc, I thought I'd make this issue before I venture further. I've only done a little bit of research on this, and am not sure if I'm likely to meet further resistance once I've worked around the bundleIdentifier check.

How to Build from Source?

While I know Desktop Notifier can be installed via pip, I was trying to build this from source; unfortunately, I'm not terribly familiar with Python and couldn't quite figure out which are the right commands to run. Without the setup.py file, I'm at a bit out of familiarity.

No easy way of icon disabling

  • Desktop Notifier version: 3.4.0
  • Python version: 3.10.7
  • Operating System: ArchLinux

Description

I could not find easy way, how to suppress notification icon. Culprit is this code:

        if not icon:
            icon = self.app_icon
        elif isinstance(icon, Path):
            icon = icon.as_uri()

I'd expect eg. empty string to disable icon, but empty string evaluates to False.
Is a better way?

Issue with request_autharization

  • Desktop Notifier version: 3.5.6
  • Python version: 3.11.1
  • Operating System: Windows 11

Description

I am trying to push a notification like this:

notifier = DesktopNotifier("SyncLyrics", ICON_URL)
await notifier.send(title="SyncLyrics", message="wow")

But I get this error:

Traceback (most recent call last):
  File "C:\Users\Kostas\Desktop\Programming\SyncLyrics\sync_lyrics.py", line 122, in <module>
    asyncio.run(main())
  File "C:\Users\Kostas\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Kostas\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Kostas\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Kostas\Desktop\Programming\SyncLyrics\sync_lyrics.py", line 105, in main
    await notifier.send(title="SyncLyrics", message=lyric)
  File "C:\Users\Kostas\Desktop\Programming\SyncLyrics\env\Lib\site-packages\desktop_notifier\main.py", line 317, in send   
    return await self.send_notification(notification)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Kostas\Desktop\Programming\SyncLyrics\env\Lib\site-packages\desktop_notifier\main.py", line 223, in send_notification
    await self.request_authorisation()
  File "C:\Users\Kostas\Desktop\Programming\SyncLyrics\env\Lib\site-packages\desktop_notifier\main.py", line 203, in request_authorisation
    return await self._impl.request_authorisation()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Kostas\Desktop\Programming\SyncLyrics\env\Lib\site-packages\desktop_notifier\winrt.py", line 98, in request_authorisation
    return bool(self.notifier.setting == NotificationSetting.ENABLED)
                ^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError -2147023728] Element not found

What I Did

By the way I saw some related closed issues, maybe the issue (or a similar one) is back. Just adding a return statement on the top of request_authorisation (just avoiding to run the function) fixes the problem and notifications are pushed perfectly.

    async def request_authorisation(self) -> bool:
        """
        Requests authorisation to send user notifications. This will be automatically
        called for you when sending a notification for the first time. It also can be
        called manually to request authorisation in advance.

        On some platforms such as macOS and iOS, a prompt will be shown to the user
        when this method is called for the first time. This method does nothing on
        platforms where user authorisation is not required.

        :returns: Whether authorisation has been granted.
        """

        return # The holly statement that fixes everything
        with self._lock:
            self._did_request_authorisation = True
            return await self._impl.request_authorisation()

PS:
I hope you don't hate me for finding issues every 5 days like I am a workaholic tester that has a beef with you.

Allow setting custom notifications sounds

Is your feature request related to a problem? Please describe.
Currently, there is only support for turning notification sounds off (default) or on. When enabled, the platform's default sound for notifications will be used, if available. It would be nice to support custom sounds.

Describe the solution you'd like
Ideally, we would allow specifying either:

  1. an identifier for a platform-provided sound
  2. the path to a sound file

Both options will require some abstraction over platform differences: macOS only provides two notification sounds, default and critical, and critical alerts require a special entitlement issued by Apple. Linux desktops typically allow using all platforms sounds from the sound-theme-spec. Both platforms allow specifying sound files but supported audio formats will be limited. In addition, macOS requires the sound file to be stored either in the app bundle or in the /Library/Sounds directory of the app's container directory (see the UNNotificationSound docs). It therefore appears that custom sound files are only support from bundled apps.

Describe alternatives you've considered
Keep the sound option as is: default or nothing.

MacOS: make notifications pile up until dismissed?

  • Desktop Notifier version: 3.5.6
  • Python version: 3.9.6
  • Operating System: MacOS 13.4.1

Description

I want to see notifications add, and add, until dismissed - whether one at a time or en masse.

Instead, one notification dismisses another, so I only see one at a time. Dismissing notification n+1 does not expose notification n.

I'm testing with urgency=Urgency.Critical, but it doesn't appear to be enough. Does relevancy or something control this?

Here's the test script:

#!/usr/bin/python3

import asyncio
from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField

notifier = DesktopNotifier()

async def main():
  await notifier.send(
      title="Julius Caesar",
      message="Et tu, Brute?",
      urgency=Urgency.Critical,
      buttons=[
        Button(
          title="Mark as read",
          on_pressed=lambda: print("Marked as read")),
      ],
      reply_field=ReplyField(
        title="Reply",
        button_title="Send",
        on_replied=lambda text: print("Brutus replied:", text),
      ),
      on_clicked=lambda: print("Notification clicked"),
      on_dismissed=lambda: print("Notification dismissed"),
      sound=True,
  )
  

loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()

OSError on Windows

  • Desktop Notifier version: 3.4.1
  • Python version: Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
  • Operating System: Windows 10 Pro 21H2 19044.2130
  • Virtualenv: packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
$ pip freeze
desktop-notifier==3.4.1
packaging==21.3
pyparsing==3.0.9
winsdk==1.0.0b7

What I Did

I tried to run basic example on README

Result

Traceback (most recent call last):
  File "C:\Users\ilker\Desktop\dev\env-trash\desktop-notifier\main.py", line 4, in <module>
    notifier = DesktopNotifier()
  File "C:\Users\ilker\Desktop\dev\env-trash\desktop-notifier\venv\lib\site-packages\desktop_notifier\main.py", line 161, in __init__
    self._impl = impl_cls(app_name, app_icon, notification_limit)
  File "C:\Users\ilker\Desktop\dev\env-trash\desktop-notifier\venv\lib\site-packages\desktop_notifier\winrt.py", line 74, in __init__
    self.notifier = self.manager.create_toast_notifier(self._appid)
OSError: [WinError -2147024809] Parametre hatalı

Parametre hatalı -> The parameter is incorrect (in english)

Crash on import

  • Desktop Notifier version: 3.5.4 (the latest in pypi right now)
  • Python version: 3.10.6
  • Operating System: Ubuntu 20.04

The library cannot be imported from a virtual environment using venv.

I simply tried to:

from desktop_notifier import DesktopNotifier

And got with this traceback:

Traceback (most recent call last):
  File "/home/kostas/programming/lyrics-app/main.py", line 4, in <module>
    from desktop_notifier import DesktopNotifier
  File "/home/kostas/programming/lyrics-app/env/lib/python3.10/site-packages/desktop_notifier/__init__.py", line 2, in <module>
    from .main import DesktopNotifier, Button, ReplyField, Notification, Urgency
  File "/home/kostas/programming/lyrics-app/env/lib/python3.10/site-packages/desktop_notifier/main.py", line 29, in <module>
    from .base import (
  File "/home/kostas/programming/lyrics-app/env/lib/python3.10/site-packages/desktop_notifier/base.py", line 22, in <module>
    from importlib_resources import path as resource_path
ImportError: cannot import name 'path' from 'importlib_resources' (/home/kostas/programming/lyrics-app/env/lib/python3.10/site-packages/importlib_resources/__init__.py

Docs failing :'( How to change icon ?

  • Desktop Notifier version: pip latest version
  • Python version: 3.10.9
  • Operating System: Arch

Hello, love the project, but i cant agree more with #32 , the readme.md could get a new look.

In the base.py you have all those parameters :

class Notification:
    """A desktop notification
    :param title: Notification title.
    :param message: Notification message.
    :param urgency: Notification level: low, normal or critical.
    :param icon: URI for an icon to use for the notification or icon name.
    :param buttons: A list of buttons for the notification.
    :param reply_field: An optional reply field/
    :param on_clicked: Callback to call when the notification is clicked. The
        callback will be called without any arguments.
    :param on_dismissed: Callback to call when the notification is dismissed. The
        callback will be called without any arguments.
    :attachment: URI for an attachment to the notification.
    :param sound: Whether to play a sound when the notification is shown.
    :param thread: An identifier to group related notifications together.
    :param timeout: Duration for which the notification in shown.
    """

but only 8 params are showed in the readme :(

what if i want to change the icon of the notification or if i want my notification to never timed out ?

Is there any way to use a relative path to custom icon ?
Currently using this :
icon="file:///home/justalternate/Projects/PokeNotif/assets/icon.png"

Something like this would be cool :
icon = "assets/icon.png"

Consider moving to async API?

Most of the platform APIs to schedule notifications and interact with the platform's notification centre are asynchronous:

  1. The dbus-next library exposes only non-blocking methods.
  2. Many of the User Notifications Framework methods are asynchronous: they return immediately and accept a callback to be invoked with the result or error.
  3. Subscribing to events for user interactions with a notification requires a running event loop.

For those reasons, the business of dealing with desktop notifications is inherently async. However, async methods may be difficult to use under particular circumstances and there is value in just firing a non-interactive notification without starting an event loop. For this reason, desktop-notifier provides a synchronous interface where possible. The only exception is DesktopNotifier.request_authorisation() which would otherwise block until the user has granted or denied authorisation. Instead, this method accepts a callback.

Moving the public API to async methods would have the following advantages:

  1. Cleaner backend implementations: we no longer need to convert asynchronous method calls to blocking calls.
  2. We don't block on IO. This will be only a small advantage, none of the current methods block for longer than a few milliseconds at most. But it can make a difference for GUI programming.

A possible alternative would be to offer both synchronous and asynchronous methods in the main API and handle any conversion there instead of in the backends.

example code has a runtime exception: SyntaxError: invalid syntax

  • Desktop Notifier version: latest
  • Python version: 3.8
  • Operating System: macOS 15 m1

Description

example code

import asyncio
from desktop_notifier import DesktopNotifier

notify = DesktopNotifier()

async def main():
    n = await notify.send(title="Hello world!", message="Sent from Python")

    await notify.clear(n)  # removes the notification
    await notify.clear_all()  # removes all notifications for this app

asyncio.run(main())

run python ./notify.py

  File "./notify.py", line 6
    async def main():
            ^
SyntaxError: invalid syntax

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Windows support

Windows support is currently still missing since I have no experience with Windows GUI frameworks.

Different options may be:

  1. Use win32 and the Shell_NotifyIconW API documented here. Advantages: Can be used from pure Python code using ctypes.windll. See plyer for an example implementation. Disadvantages: Does not appear to support buttons.
  2. Use Toast Notification API as documented here. Advantages: Simpler API. Richer UI with buttons etc. Disadvantages: Likely requires a package such as pythonnet with extension modules.

Example code not working on mac os

  • Desktop Notifier version: 3.3.2
  • Python version: 3.9.0
  • Operating System: Mac OS (11.6)

Description

i am trying to run the most simple example of code that's in the Readme file and getting this message:
Notification Center can only be used from a signed Framework or app bundle
when reading the Readme file there is a section about signed apps, but the part about passing the macos_legacy param is wrong - the param is not in the code as an option.

What I Did

In Terminal:

conda create --name mac-notifier-playground python=3.9 -y
conda activate mac-notifier-playground
pip install desktop-notifier

In Code:

import asyncio
from desktop_notifier import DesktopNotifier

notify = DesktopNotifier(app_name="Sample App")


async def main():
    n = await notify.send(title="Hello world!", message="Sent from Python")

    await asyncio.sleep(5)  # wait a bit before clearing notification

    await notify.clear(n)  # removes the notification
    await notify.clear_all()  # removes all notifications for this app


asyncio.run(main())

Output:

Notification Center can only be used from a signed Framework or app bundle

ValueError: No method was found starting with 'addObject' and with keywords set()

  • Operating System: macOS 12.3 Intel chip

Description

As per samschott/maestral#516 (comment)
and request to log samschott/maestral#516 (comment)

When starting the sync via terminal, following error is generated;

Notification failed
Traceback (most recent call last):
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 206, in __call__
KeyError: frozenset({''})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Contents/Resources/app_packages/desktop_notifier/base.py", line 204, in send
  File "Contents/Resources/app_packages/desktop_notifier/macos.py", line 252, in _send
  File "Contents/Resources/app_packages/desktop_notifier/macos.py", line 366, in _create_category_for_notification
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 236, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 215, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 153, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 1519, in ns_from_py
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 236, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 208, in __call__
ValueError: No method was found starting with 'addObject' and with keywords set()
Known keywords are:
frozenset({'toPropertyWithKey', ''})
frozenset({'', 'toBothSidesOfRelationshipWithKey'})

python.png went missing when changing the build system

  • Desktop Notifier version: 3.3.3
  • Python version: 3.9
  • Operating System: Gentoo Linux

Description

resources/python.png is missing in v3.3.3

What I Did

$ maestral start
Starting Maestral...Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/maestral/daemon.py", line 375, in start_maestral_daemon
    from .main import Maestral
  File "/usr/lib/python3.9/site-packages/maestral/main.py", line 41, in <module>
    from .sync import SyncDirection
  File "/usr/lib/python3.9/site-packages/maestral/sync.py", line 69, in <module>
    from . import notify
  File "/usr/lib/python3.9/site-packages/maestral/notify.py", line 13, in <module>
    from desktop_notifier import DesktopNotifier, Urgency, Button
  File "/usr/lib/python3.9/site-packages/desktop_notifier/__init__.py", line 2, in <module>
    from .main import DesktopNotifier, Button, ReplyField, Notification, Urgency
  File "/usr/lib/python3.9/site-packages/desktop_notifier/main.py", line 30, in <module>
    from .base import (
  File "/usr/lib/python3.9/site-packages/desktop_notifier/base.py", line 21, in <module>
    PYTHON_ICON_PATH = path("desktop_notifier.resources", "python.png").__enter__()
  File "/usr/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/usr/lib/python3.9/importlib/resources.py", line 175, in _path_from_reader
    opener_reader = reader.open_resource(norm_resource)
  File "<frozen importlib._bootstrap_external>", line 1055, in open_resource
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.9/site-packages/desktop_notifier/resources/python.png'

Cannot fire a notification without default button

  • Desktop Notifier version: 3.5.3
  • Python version: 3.11.3
  • Operating System: Arch Linux
  • Desktop environment: Xfce 4.18

Description

I'm trying to run a simple notification without a button, but default button keeps poping up. I went through docs twice but obviously I'm still missing some obvious way to disable it.

image

What I Did

import asyncio
from desktop_notifier import DesktopNotifier

notifier = DesktopNotifier()

async def main():
  await notifier.send(
      title="Julius Caesar",
      message="Et tu, Brute?",
      icon=f"{icons}/selection/check.svg",
      timeout=5
  )

asyncio.run(main())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.