| 1 |
#!/usr/bin/env python |
|---|
| 2 |
|
|---|
| 3 |
import sys |
|---|
| 4 |
import dbus |
|---|
| 5 |
import gobject |
|---|
| 6 |
|
|---|
| 7 |
from dbus.mainloop.glib import DBusGMainLoop |
|---|
| 8 |
|
|---|
| 9 |
DBusGMainLoop(set_as_default=True) |
|---|
| 10 |
|
|---|
| 11 |
session_bus = dbus.SessionBus() |
|---|
| 12 |
notifications_object = session_bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') |
|---|
| 13 |
notifications_interface = dbus.Interface(notifications_object, 'org.freedesktop.Notifications') |
|---|
| 14 |
|
|---|
| 15 |
def handler(id, action_key): |
|---|
| 16 |
print "action invoked: %r" % action_key |
|---|
| 17 |
loop.quit() |
|---|
| 18 |
|
|---|
| 19 |
notifications_interface.connect_to_signal("ActionInvoked", handler) |
|---|
| 20 |
|
|---|
| 21 |
try: |
|---|
| 22 |
id = notifications_interface.Notify("test", 0, '', 'Test message', 'First', ['open', 'Open'], {'x': 100, 'y': 100}, -1) |
|---|
| 23 |
|
|---|
| 24 |
# Modifying a notification crashes notification-daemon when using the Bubble theme |
|---|
| 25 |
id = notifications_interface.Notify("test", id, '', 'Test message', 'Second', ['open', 'Open'], {'x': 100, 'y': 100}, -1) |
|---|
| 26 |
except dbus.exceptions.DBusException: |
|---|
| 27 |
print 'Failed to show notification' |
|---|
| 28 |
else: |
|---|
| 29 |
loop = gobject.MainLoop() |
|---|
| 30 |
loop.run() |
|---|
| 31 |
|
|---|