Ivan Vučica avatar Ivan Vučica committed 17f63f2 Draft

Example of sending dbus notification via Python

Comments (0)

Files changed (1)


+#!/usr/bin/env python
+# source:
+# http://askubuntu.com/a/38796
+import dbus, dbus.proxies
+#-- connect to the session bus, as opposed to the system bus
+session = dbus.SessionBus()
+#-- create proxy object of D-Bus object
+obj_proxy = dbus.proxies.ProxyObject(conn=session,
+         bus_name="org.freedesktop.Notifications",     #-- name of the service we are retrieving object from
+         object_path="/org/freedesktop/Notifications") #-- the object path
+#-- create proxy object of the D-Bus object wrapped into specific interface
+intf_proxy = dbus.proxies.Interface(obj_proxy, "org.freedesktop.Notifications")
+#-- lastly, create proxy object of the D-Bus method
+method_proxy = intf_proxy.get_dbus_method("Notify")
+#-- ... and call the method
+method_proxy("test from python",
+             dbus.UInt32(0),
+             "bluetooth",     #-- icon name
+             "Notification summary",
+             "Here goes notification body",
+             [], {},
+             2) #-- timeout
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.