OBus is a pure OCaml implementation of the D-Bus protocol. It aims to provide a clean and easy way for ocaml programmers to access and provide D-Bus services.
OBus uses the cooperative threading library Lwt, which makes it very simple to fully exploit the asynchronous nature of D-Bus.
The recommended way to install obus and its dependencies is via
opam: opam install obus
.
Make sure you have dune installed, and install all the missing dependencies listed in the output of this command:
$ dune external-lib-deps @install --missing
Then you can build and install obus:
$ dune build -p obus
$ dune install -p obus
To build and execute tests:
$ dune runtest
OBus installs the following packages:
obus
: the core library, implementing the D-Bus protocol.obus.ppx
: syntax extensions to aid registering OBus exceptions.- Interfaces to various freedesktop dbus services:
obus.notification
,obus.network_manager
,obus.hal
,obus.upower
,obus.udisks
,obus.policykit
.
There are several tools provided in the obus distribution:
obus-dump
, to execute a command and dump all messages that go through the session and/or system message bus.obus-introspect
which can recursively introspect a D-Bus service.obus-gen-interface
, to convert D-Bus introspection files into ocaml definition modules.obus-gen-client
andobus-gen-server
, which can generate templates for using or implementing D-Bus services.obus-xml2idl
andobus-idl2xml
, to convert xml introspection documents to the obus idl format, and vice versa.
There are manual pages for all this tools.
Introspection files do not contain enough information to create usable
bindings by themselves, so the files generated by obus-gen-client
and
obus-gen-server
are only stubs meant to be edited and adapted.
Here is a simple example of use of the tools:
$ obus-introspect org.freedesktop.Notifications /org/freedesktop/Notifications > notif.xml
$ obus-gen-interface notif.xml
$ obus-gen-client notif.xml