Content-type: text/html
dbus-launch [--version] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session] [--config-file=FILENAME] [PROGRAM] [ARGS...]
The dbus-launch command is used to start dbus-daemon from a shell script. It would normally be called from a user's login scripts. Unlike the daemon itself, dbus-launch exits, so backticks or the $() construct can be used to read information from dbus-launch.
With no arguments, dbus-launch will simply print the values of DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID.
You may specify a program to be run; in this case, dbus-launch will then set the appropriate environment variables and execute the specified program, with the specified arguments. See below for examples.
Finally, you may use the --sh-syntax, --csh-syntax, or --auto-syntax commands to cause dbus-launch to emit shell code to set up the environment. This is useful in shell scripts.
With the --auto-syntax option, dbus-launch looks at the value of the SHELL environment variable to determine which shell syntax should be used. If SHELL ends in "csh", then csh-compatible code is emitted; otherwise Bourne shell code is emitted. Instead of passing --auto-syntax, you may explicity specify a particular one by using --sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. In scripts, it's more robust to avoid --auto-syntax and you hopefully know which shell your script is written in.
See http://www.freedesktop.org/software/dbus/ for more information about D-BUS. See also the man page for dbus-daemon.
Here is an example of how to use dbus-launch with an sh-compatible shell to start the per-session bus daemon:
## test for an existing bus daemon, just to be safe
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
## if not found, launch a new one
eval `dbus-launch --sh-syntax --exit-with-session`
echo "D-BUS per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
fi
You might run something like that in your login scripts.
Another way to use dbus-launch is to run your main session program, like so:
dbus-launch gnome-sessionThe above would likely be appropriate for ~/.xsession or ~/.Xclients.