When I tried to run notify-send on my laptop running Gentoo, it didn’t work and was given the following message:

$ notify-send 'hello'
Connecting to D-Bus failed: Using X11 for dbus-daemons autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead

How do one set DBUS_SESSION_BUS_ADDRESS? Accoridng to this, it can be done by running:

$ export $(dbus-launch)

However, I want to also have D-Bus compiled with X11 support.

First let’s verify if D-Bus service is running:

 # systemctl status dbus
● dbus.service - D-Bus System Message Bus
   Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: disabled)
   Active: active (running) since Tue 2019-01-15 14:21:55 AEDT; 44min ago
     Docs: man:dbus-daemon(1)
 Main PID: 5253 (dbus-daemon)
   CGroup: /system.slice/dbus.service
           └─5253 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Next, let’s check the compile flags of dbus package:

# eix sys-apps/dbus
[I] sys-apps/dbus
     Available versions:  1.10.18^t 1.10.24 ~1.12.12 {X debug doc elogind selinux static-libs systemd test user-session ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="linux"}
     Installed versions:  1.10.24(02:58:49 PM 01/15/2019)(systemd user-session -X -debug -doc -elogind -selinux -static-libs -test ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" KERNEL="linux")
     Homepage:            https://dbus.freedesktop.org/
     Description:         A message bus system, a simple way for applications to talk to each other

From the above out put X flag wasn’t set for sys-apps:

# echo 'sys-apps/dbus systemd user-session X' > /etc/portage/package.use/dbus
# emerge -av sys-apps/dbus

After that, I could verify that D-Bus was running correctly.