DBUS-RUN-SESSION(1)

โœจ DBUS-RUN-SESSION โœจ

okay so bestie, welcome to dbus-run-session โ€” it's a User Commands situation and honestly it's giving "tiny tool, big main character energy" ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

dbus-run-session โ€” start a process as a new D-Bus session. that's it. that's the whole vibe. ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

dbus-run-session [--config-file FILENAME] [--dbus-daemon BINARY] [--]
                 PROGRAM [ARGUMENTS...]

dbus-run-session --help

dbus-run-session --version

like, you give it a program, it gives that program a whole fresh session bus. match made in heaven fr fr ๐Ÿ’–


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

so dbus-run-session is used to start a session bus instance of dbus-daemon from a shell script, and then start a specified program in that session. the dbus-daemon will run for as long as the program does, after which it will terminate. iconic behaviour, no notes ๐Ÿ‘‘

one use is to run a shell with its own dbus-daemon in a text-mode or SSH session, and have the dbus-daemon terminate automatically on leaving the sub-shell, like this:

dbus-run-session -- bash

or, if you wanna replace the login shell altogether, by combining dbus-run-session with the exec builtin:

exec dbus-run-session -- bash

another use โ€” and this one is lowkey the bestie-coded one โ€” is to run regression tests and similar things in an isolated D-Bus session, so you avoid either interfering with the "real" D-Bus session or relying on there already being a D-Bus session active, for instance:

dbus-run-session -- make check

or (in automake(1)):

      AM_TESTS_ENVIRONMENT = export MY_DEBUG=all;
      LOG_COMPILER = dbus-run-session
      AM_LOG_FLAGS = --

see how clean that is? no cap, it ate ๐ŸŒˆ


๐ŸŽ€ OPTIONS ๐ŸŽ€

  • --config-file=FILENAME, --config-file FILENAME โ€” pass --config-file=FILENAME to the bus daemon, instead of passing it the --session argument. see dbus-daemon(1). ๐Ÿ’ซ
  • --dbus-daemon=BINARY, --dbus-daemon BINARY โ€” run BINARY as dbus-daemon(1), instead of searching the PATH in the usual way for an executable called dbus-daemon. you pick the daemon, you're the main character now ๐Ÿซถ
  • --help โ€” print usage information and exit. ๐Ÿงš
  • --version โ€” print the version of dbus-run-session and exit. โญ

๐Ÿ’€ EXIT STATUS ๐Ÿ’€

okay listen, this part matters, don't skip it:

dbus-run-session exits with the exit status of PROGRAM, 0 if the --help or --version options were used, 127 on an error within dbus-run-session itself, or 128+n if the PROGRAM was killed by signal n.

like, it's literally just passing the vibes through ๐Ÿ˜ญ


๐Ÿฆ‹ ENVIRONMENT ๐Ÿฆ‹

PATH is searched to find PROGRAM, and (if the --dbus-daemon option is not used or its argument does not contain a / character) to find dbus-daemon. so yeah, PATH is doing a lot of heavy lifting here ๐Ÿซก

the session bus' address is made available to PROGRAM in the environment variable DBUS_SESSION_BUS_ADDRESS. cute little handoff ๐Ÿ’Œ

the variables DBUS_SESSION_BUS_PID, DBUS_SESSION_BUS_WINDOWID, DBUS_STARTER_BUS_TYPE and DBUS_STARTER_ADDRESS are removed from the environment, if present. yeah, they get yeeted ๐Ÿ™ˆ


๐Ÿ”ฅ BUGS ๐Ÿ”ฅ

please send bug reports to the D-Bus mailing list or bug tracker, see https://www.freedesktop.org/wiki/Software/dbus/

(no gatekeeping, they wanna hear from you ๐Ÿ’œ)


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

see https://dbus.freedesktop.org/doc/AUTHORS


๐ŸŒธ SEE ALSO ๐ŸŒธ

dbus-daemon(1), dbus-launch(1)


that's the whole page bestie, go forth and session-bus responsibly ๐Ÿ“

this has been D-Bus 1.16.2, dated 03/03/2025 โ€” mwah, ily, bye ๐Ÿ’…๐Ÿ’–

๐Ÿ“ฆ where this page comes from