import dbus, dbus.service import gobject from dbus.mainloop.glib import DBusGMainLoop class SysTrayService(dbus.service.Object): def __init__(self): DBusGMainLoop(set_as_default=True) bus_name = dbus.service.BusName("org.freedesktop.Notifications", bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, "/org/freedesktop/Notifications") @dbus.service.method("org.freedesktop.Notifications") def Notify(self, app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout): print(app_name) print(summary + "\n" + body) if __name__ == "__main__": systray = SysTrayService() loop = gobject.MainLoop() loop.run()