Skip to content

Custom icons are not showing on Linux #57

Description

@white43

Here is the minimal code to reproduce the issue.

from notifypy import Notify

n = Notify(enable_logging=True)
n.send()

The above code snippet results in the following notification on Arch Linux.
Screenshot_2023-12-03_21-10-08

While the output in stdout shows the following:

2023-12-03 21:22:11.679 | INFO     | notifypy.notify:__init__:50 - Logging is enabled.
2023-12-03 21:22:11.685 | INFO     | notifypy.os_notifiers.linux:<module>:16 - libnotify found, using it for notifications
2023-12-03 21:22:11.685 | DEBUG    | notifypy.os_notifiers.linux:<module>:28 - aplay binary not installed.. audio will not work!
2023-12-03 21:22:11.686 | DEBUG    | notifypy.os_notifiers.linux:send_notification:74 - Generated command: ['/usr/bin/notify-send', 'Default Title', 'Default Message', "--icon='/home/white/study/SDM404/Assessment 3/SDM404 Final Project/venv/lib/python3.11/site-packages/notifypy/py-logo.png'", "--app-name='Python Application (notify.py)'", '-u', 'normal']
2023-12-03 21:22:11.704 | INFO     | notifypy.notify:send_notification:351 - Sent notification.

It is because of unnecessary extra quotation while calling:

if notification_icon:
generated_command.append(f"--icon={shlex.quote(notification_icon)}")

According to the subprocess documentation, it takes over argument quotation if needed. After a small correction it works like a charm.

if notification_icon:
    generated_command.extend(['--icon', notification_icon])

if kwargs.get("application_name"):
    generated_command.extend(['--app-name', kwargs.get('application_name')])

Screenshot_2023-12-03_21-28-38

2023-12-03 21:25:46.435 | INFO     | notifypy.notify:__init__:50 - Logging is enabled.
2023-12-03 21:25:46.441 | INFO     | notifypy.os_notifiers.linux:<module>:16 - libnotify found, using it for notifications
2023-12-03 21:25:46.441 | DEBUG    | notifypy.os_notifiers.linux:<module>:28 - aplay binary not installed.. audio will not work!
2023-12-03 21:25:46.441 | DEBUG    | notifypy.os_notifiers.linux:send_notification:72 - Generated command: ['/usr/bin/notify-send', 'Default Title', 'Default Message', '--icon', '/home/white/study/SDM404/Assessment 3/SDM404 Final Project/venv/lib/python3.11/site-packages/notifypy/py-logo.png', '--app-name', 'Python Application (notify.py)', '-u', 'normal']
2023-12-03 21:25:46.457 | INFO     | notifypy.notify:send_notification:351 - Sent notification.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions