Fixed D-Bus session address in Void Linux

January 5, 2026

I want to schedule a script with crontab(1) to send a desktop notification when the battery drops to 20 percent. Here, notify-send(1) needs the D-bus session to communicate with the notification daemon Mako.

One approach is to export DBUS_SESSION_BUS_ADDRESS to the crontab environment using the random address from ~/.dbus/session-bus/1. However, I prefer setting a fixed address for dbus-daemon(1), since some software expects /run/user/1000 due to systemd2. This makes exporting DBUS_SESSION_BUS_ADDRESS unnecessary.

My setup

Ensure that XDG_RUNTIME_DIR is set to /run/user/$(id -u), which resolves to /run/user/1000 for the first non-root user. I use the Turnstile session manager, but there are other options.

Then, start a window manager or another program with dbus-run-session(1) in a login shell or login manager, such as greetd. I use the Wayland compositor River:

exec dbus-run-session --config-file="~/.config/dbus/session.conf" river

Note that the --config-file option specifies a configuration file for dbus-daemon. I copied the file /usr/share/dbus-1/session.conf and set a fixed address using the <listen> directive:

<listen>unix:path=/run/user/1000/bus</listen>

After login back in, $DBUS_SESSION_BUS_ADDRESS should be set to unix:path=/run/user/1000/bus.

Notes

This workaround may also apply to other systemd-free systems besides Void Linux, but I’ve only tested it on this setup, where I've seen this question before.

RSS
https://ctrleon.page/posts/feed.xml