2

I am trying to play with libnotify's python bindings. I got this code from /usr/share/doc/python-notify/examples and it is showing different behaviour with xfce4-notifyd and notify-osd.

Case-1 with xfce4-notifyd

enter image description here

Case-2 with notify-osd

enter image description here

You can see the difference in both the cases. In 1st case the action is integrated in the form of button in xfce4-notifyd whereas in 2nd case this is not happening. In 2nd case it just shows up as a new window.

So, can anyone tell me why I am observing this weird behaviour and how do I add action buttons to notify-osd notifications.

PS: I am using the patched version of notify-osd. My default notifications with notify-osd looks like

enter image description here

1 Answer 1

1

Notify-osd does not handle actions. This is an explicit design decision by the developers. As the design spec states, "Other than that hover effect, bubbles should not directly respond to input devices in any way." The it also asserts that when actions are requested, it will fallback to an alert box:

For cases where applications have expected the notification system to allow interactivity without checking whether it actually does, and cases where applications have expected the notification system to display a notification indefinitely, Notify OSD should show an alert box as a fallback.

While it's up for debate whether or not that is a good decision, Notify-osd is an implementation of the Freedesktop notification spec, which clearly states that it is the responsiblity of the client to make sure the server supports the desired ability:

Clients should try and avoid making assumptions about the presentation and abilities of the notification server. The message content is the most important thing.

Clients can check with the server what capabilities are supported using the GetCapabilities message.

You can test for notification server capabilities with something like:

import pynotify

pynotify.init("Test Capabilities")
caps = pynotify.get_server_caps()

if caps and 'actions' in caps:
    # We support actions, so add a button.
    notification = pynotify.Notification("Can we use actions?", \
                                         "Yup, we sure do.")
    notification.add_action("ignore", "Ignore", ignore_cb)
else:
    notification = pynotify.Notification("Can we use actions?", \
                                         "Nope, we don't support actions.")
notification.show()

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .