Introduction to D-Bus
        
        
          D-Bus is a message bus system, a
          simple way for applications to talk to one another. D-Bus supplies both a system daemon (for
          events such as “new
          hardware device added” or “printer queue changed”)
          and a per-user-login-session daemon (for general IPC needs among
          user applications). Also, the message bus is built on top of a
          general one-to-one message passing framework, which can be used by
          any two applications to communicate directly (without going through
          the message bus daemon).
        
        
          ![[Note]](../images/note.png) 
          
            Note
          
          
            Development versions of BLFS may not build or run some packages
            properly if LFS or dependencies have been updated since the most
            recent stable versions of the books.
          
         
        
          Package Information
        
        
        
          D-Bus Dependencies
        
        
          Recommended
        
        
          Xorg
          Libraries (for dbus-launch program)
        
        
          Optional
        
        
          For the tests: D-Bus
          Python-1.4.0, PyGObject-3.52.3, and Valgrind-3.26.0; for
          documentation: Doxygen-1.15.0, xmlto-0.0.29,
          Ducktype, and
          Yelp Tools
        
       
      
        
          Installation of D-Bus
        
        
          Install D-Bus by running the
          following commands (you may wish to review the meson_options.txt
          file first and add any additional desired options to the meson
          setup line below):
        
        mkdir build &&
cd    build &&
meson setup --prefix=/usr          \
            --buildtype=release    \
            --wrap-mode=nofallback \
            -D systemd=disabled    \
            .. &&
ninja
        
          See below for test instructions.
        
        
          Now, as the root user:
        
        ninja install
        
          If you are using a DESTDIR install, dbus-daemon-launch-helper needs
          to be fixed afterwards. Issue, as root user:
        
        chown -v root:messagebus /usr/libexec/dbus-daemon-launch-helper &&
chmod -v      4750       /usr/libexec/dbus-daemon-launch-helper
        
          If you are still building your system in chroot or you did not
          start the daemon yet, but you want to compile some packages that
          require D-Bus, generate the
          D-Bus UUID to avoid warnings when
          compiling some packages with the following command as the
          root user:
        
        dbus-uuidgen --ensure
        
          If using elogind-255.17, create a symlink to the
          /var/lib/dbus/machine-id file:
        
        ln -sfv /var/lib/dbus/machine-id /etc
        
          Finally, still as the root user,
          rename the documentation directory (it only exists if the optional
          dependencies are satisfied for at least one documentation format)
          to make it versioned:
        
        if [ -e /usr/share/doc/dbus ]; then
  rm -rf /usr/share/doc/dbus-1.16.2    &&
  mv -v  /usr/share/doc/dbus{,-1.16.2}
fi
        
          Many tests are disabled unless both D-Bus
          Python-1.4.0 and PyGObject-3.52.3 have been installed. They
          must be run as an unprivileged user from a local session with bus
          address. To run the standard tests issue ninja test.
        
        
          If you want to run the unit regression tests, meson requires
          additional parameters which expose additional functionality in the
          binaries that are not intended to be used in a production build of
          D-Bus. If you would like to run
          the tests, issue the following commands (for the tests, you don't
          need to build the docs):
        
        meson configure -D asserts=true -D intrusive_tests=true &&
ninja test
       
      
        
          Command Explanations
        
        
          --wrap-mode=nofallback:
          This switch prevents meson from using subproject
          fallbacks for any dependency declarations in the build files,
          preventing it from downloading any optional dependencies which are
          not installed on the system.
        
        
          -D systemd=disabled: Don't
          install systemd support files even if libsystemd exists (i.e. the elogind-255.17
          package is installed).
        
        
          -D intrusive_tests=true:
          Builds extra parts of the code to support all tests. Do not use on
          a production build.
        
        
          -D asserts=true: Enables
          debugging code to run assertions for statements normally assumed to
          be true. This prevents a warning that '-D asserts=true' on its own is only
          useful for profiling and might not give true results for all tests,
          but adds its own NOTE that this should not be used in a production
          build.
        
       
      
        
          Configuring D-Bus
        
        
          
            Config Files
          
          
            /etc/dbus-1/session.conf,
            /etc/dbus-1/system.conf and
            /etc/dbus-1/system.d/*
          
         
        
          
            Configuration Information
          
          
            The configuration files listed above should probably not be
            modified. If changes are required, you should create /etc/dbus-1/session-local.conf and/or
            /etc/dbus-1/system-local.conf and
            make any desired changes to these files.
          
          
            If any packages install a D-Bus
            .service file outside of the
            standard /usr/share/dbus-1/services
            directory, that directory should be added to the local session
            configuration. For instance, /usr/local/share/dbus-1/services can be added
            by performing the following commands as the root user:
          
          cat > /etc/dbus-1/session-local.conf << "EOF"
<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <!-- Search for .service files in /usr/local -->
  <servicedir>/usr/local/share/dbus-1/services</servicedir>
</busconfig>
EOF
         
        
          
            D-Bus Session Daemon
          
          
            To automatically start dbus-daemon when the system is
            rebooted, install the /etc/rc.d/init.d/dbus bootscript from the
            blfs-bootscripts-20250225 package.
          
          make install-dbus
          
            If this is the first time to install D-Bus on the system and you are not
            operating in a chroot environment, you can immediately start
            dbus-daemon without
            rebooting the system:
          
          /etc/init.d/dbus start
          
            Note that this boot script only starts the system-wide
            D-Bus daemon. Each user
            requiring access to D-Bus
            services will also need to run a session daemon as well. There
            are many methods you can use to start a session daemon using the
            dbus-launch
            command. Review the dbus-launch man page for
            details about the available parameters and options. Here are some
            suggestions and examples:
          
          
            
              - 
                
                  Add dbus-launch to the line
                  in the ~/.xinitrcfile that
                  starts your graphical desktop environment.
 
- 
                
                  If you use gdm or some other display
                  manager that calls the ~/.xsessionfile, you can add
                  dbus-launch
                  to the line in your~/.xsessionfile that starts your
                  graphical desktop environment. The syntax would be similar
                  to the example in the~/.xinitrcfile.
 
- 
                
                  The examples shown previously use dbus-launch to specify a
                  program to be run. This has the benefit (when also using
                  the --exit-with-x11parameter) of stopping the session daemon when the
                  specified program is stopped. You can also start the
                  session daemon in your system or personal startup scripts
                  by adding the following lines:
 # Start the D-Bus session daemon
eval `dbus-launch`
export DBUS_SESSION_BUS_ADDRESS
 
                  This method will not stop the session daemon when you exit
                  your shell, therefore you should add the following line to
                  your ~/.bash_logoutfile:
 # Kill the D-Bus session daemon
kill $DBUS_SESSION_BUS_PID