dbus-launch
Start a new D-Bus session bus instance
SYNOPSIS
dbus-launch [OPTIONS] [PROGRAM] [ARGS...]
PARAMETERS
--auto-syntax
Output shell syntax appropriate for the current shell (sh or csh).
--sh-syntax
Output shell syntax compatible with Bourne shell (sh, bash, zsh, etc.).
--csh-syntax
Output shell syntax compatible with C shell (csh, tcsh).
--config-file=FILENAME
Use the specified configuration file instead of the default session.conf.
--close-stderr
Close standard error when forking the bus daemon. Useful for clean script execution.
--disable-unix-fd
Do not allow passing of Unix file descriptors over the D-Bus connection.
--fork
Fork into the background after starting the D-Bus daemon. dbus-launch will not wait for the launched program.
--exit-with-session
Kill the bus daemon when the dbus-launch process exits. Ensures proper cleanup.
--help
Display a help message and exit.
--version
Display version information and exit.
PROGRAM
The program to launch after starting or connecting to the D-Bus session bus. All subsequent arguments are passed to this program.
DESCRIPTION
dbus-launch is a utility primarily used to start a D-Bus message bus from a shell script, and optionally launch a program within the context of that bus session. Its main purpose is to ensure that a program has the necessary environment variables set (specifically DBUS_SESSION_BUS_ADDRESS) to connect to and communicate over the D-Bus session bus. This is particularly useful for applications not launched by a desktop environment or session manager that would normally handle D-Bus setup.
By using dbus-launch, a program can easily find and connect to the session bus, enabling inter-process communication with other D-Bus-aware applications. It can either start a new bus daemon or connect to an existing one if the environment variables are already defined, offering flexibility for various use cases. It acts as a bridge, ensuring that the application can participate in the D-Bus communication ecosystem.
CAVEATS
- Using dbus-launch without a program or without --exit-with-session can lead to lingering D-Bus daemon processes if not properly managed.
- When launching a program, it's often crucial to use --exit-with-session if you want the bus daemon to terminate when the launched program exits, preventing orphaned processes.
- It's generally not required for applications launched via a desktop environment (like GNOME or KDE) as the session manager typically handles D-Bus setup automatically.
- Care should be taken when using --fork as dbus-launch will not wait for the launched program to finish, which might require additional process management in shell scripts.
ENVIRONMENT VARIABLES
dbus-launch is primarily responsible for setting the DBUS_SESSION_BUS_ADDRESS environment variable. This variable contains the network address of the D-Bus session bus, allowing D-Bus-aware applications to connect to it. Without this variable, applications would not know how to find and communicate with the bus daemon.
SESSION MANAGEMENT VS. PROGRAM LAUNCH
While dbus-launch can start a bus, for complete session management and a more robust D-Bus setup, especially for graphical sessions, dbus-run-session(1) is often preferred. dbus-launch is more suited for launching a single program in a D-Bus context or for simple script-based session initiation rather than managing a full desktop environment.
HISTORY
The D-Bus inter-process communication system, of which dbus-launch is a core component, was initiated by the FreeDesktop.org project in the early 2000s (around 2002-2003). It was designed to provide a standardized way for applications to communicate on Unix-like operating systems. dbus-launch emerged as an essential utility alongside the main dbus-daemon to facilitate easy integration of applications with the D-Bus session bus, particularly in environments where a full-fledged session manager might not be present or where an application needs to explicitly control its D-Bus session. Its role has remained consistent over the years, serving as a reliable method to ensure D-Bus connectivity for standalone programs or custom shell scripts.
SEE ALSO
dbus-daemon(1), dbus-send(1), dbus-monitor(1), dbus-run-session(1)