Exploring D-Bus with Emacs APIs

Updates

  • Finish your taxes!
  • I've started working on a book about building a modern desktop environment with Sway in Guix (and Linux)!

    Keep an eye out here for early access: https://ko-fi.com/SystemCrafters

Exploring D-Bus with Emacs APIs

D-Bus is a standard part of the Linux desktop environment! Emacs provides a nice set of functions for interacting with system-level and user-level D-Bus services.

We'll be exploring D-Bus with these functions in the M-x ielm REPL!

(dbus-call-method :session "org.freedesktop.Notifications" "/org/freedesktop/Notifications" "org.freedesktop.Notifications" "Notify" "SystemCrafters" 0 "" "Summary" "Body" '(:array) '(:array :signature "{sv}") :int32 -1)

Listing known D-Bus services in the user session

(dbus-list-known-names :session)

Finding all "nodes" (object paths) for a service

(dbus-introspect-get-all-nodes "org.freedesktop.portal.Documents" "/")

List all interfaces for a given node

(dbus-introspect-get-interface-names :session "org.freedesktop.portal.Documents" "/org/freedesktop/portal/documents")

Describe a particular interface

(dbus-introspect-get-interface :session "org.freedesktop.portal.Documents" "/org/freedesktop/portal/documents" "org.freedesktop.portal.Documents")

Call a simple method

(dbus-call-method :session "org.freedesktop.portal.Documents" "/org/freedesktop/portal/documents" "org.freedesktop.portal.Documents" "GetMountPoint")

Enjoyed this stream? Explore our hands-on courses for deeper, structured learning on Guile Scheme and more.

Get the System Crafters Newsletter
Updates on open source tools, tutorials, and community projects. We'll also occasionally let you know about new courses and resources.
Name (optional)
Email Address