MAN page from Fedora 16 dbus-x11-1.4.10-3.fc16.i686.rpm
Section: User Commands (1)Index
dbus-launch - Utility to start a message bus from a shell script
dbus-launch [--version] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session] [--autolaunch=MACHINEID] [--config-file=FILENAME] [PROGRAM] [ARGS...]
The dbus-launch command is used to start a session bus instance of dbus-daemon from a shell script.It would normally be called from a user's loginscripts. Unlike the daemon itself, dbus-launch exits, sobackticks or the $() construct can be used to read information fromdbus-launch.
With no arguments, dbus-launch will launch a session businstance and print the address and pid of that instance to standardoutput.
You may specify a program to be run; in this case, dbus-launchwill launch a session bus instance, set the appropriate environmentvariables so the specified program can find the bus, and then execute thespecified program, with the specified arguments. See below forexamples.
If you launch a program, dbus-launch will not print theinformation about the new bus to standard output.
When dbus-launch prints bus information to standard output, bydefault it is in a simple key-value pairs format. However, you may request several alternate syntaxes using the --sh-syntax, --csh-syntax,--binary-syntax, or--auto-syntax options. Several of these cause dbus-launch to emit shell codeto set up the environment.
With the --auto-syntax option, dbus-launch looks at the valueof the SHELL environment variable to determine which shell syntaxshould be used. If SHELL ends in "csh", then csh-compatible code isemitted; 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 hopefullyknow which shell your script is written in.
See http://www.freedesktop.org/software/dbus/ for more informationabout 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 sessionprogram, like so:
The above would likely be appropriate for ~/.xsession or ~/.Xclients.
If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to useD-Bus, by default the process will attempt to invoke dbus-launch withthe --autolaunch option to start up a new session bus or find the existing bus address on the X display or in a file in~/.dbus/session-bus/
Whenever an autolaunch occurs, the application that had tostart a new bus will be in its own little world; it can effectivelyend up starting a whole new session if it tries to use a lot of bus services. This can be suboptimal or even totally broken, dependingon the app and what it tries to do.
There are two common reasons for autolaunch. One is ssh to a remotemachine. The ideal fix for that would be forwarding ofDBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded.In the meantime, you can edit the session.conf config file to have your session bus listen on TCP, and manually setDBUS_SESSION_BUS_ADDRESS, if you like.
The second common reason for autolaunch is an su to another user, anddisplay of X applications running as the second user on the displaybelonging to the first user. Perhaps the ideal fix in this casewould be to allow the second user to connect to the session bus of thefirst user, just as they can connect to the first user's display.However, a mechanism for that has not been coded.
You can always avoid autolaunch by manually settingDBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the defaultaddress if none is set is "autolaunch:", so if any other address isset there will be no autolaunch. You can however include autolaunch inan explicit session bus address as a fallback, for exampleDBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case ifthe first address doesn't work, processes will autolaunch. (The busaddress variable contains a comma-separated list of addresses to try.)
The --autolaunch option is considered an internal implementationdetail of libdbus, and in fact there are plans to change it. There'sno real reason to use it outside of the libdbus implementation anyhow.
The following options are supported:
- Choose --csh-syntax or --sh-syntax based on the SHELL environment variable.
--binary-syntaxWrite to stdout a nul-terminated bus address, then the bus PID as abinary integer of size sizeof(pid_t), then the bus X window ID as abinary integer of size sizeof(long). Integers are in the machine'sbyte order, not network byte order or any other canonical byte order.
- Close the standard error output stream before starting the D-Busdaemon. This is useful if you want to capture dbus-launch errormessages but you don't want dbus-daemon to keep the stream open toyour application.
- Pass --config-file=FILENAME to the bus daemon, instead of passing it the --session argument. See the man page for dbus-daemon
- Emit csh compatible code to set up environment variables.
- If this option is provided, a persistent "babysitter" process will be created that watches stdin for HUP and tries to connect to the Xserver. If this process gets a HUP on stdin or loses its X connection,it kills the message bus daemon.
- This option implies that dbus-launch should scan for apreviously-started session and reuse the values found there. If nosession is found, it will start a new session. The--exit-with-session option is implied if --autolaunch is given.This option is for the exclusive use of libdbus, you do not want touse it manually. It may change in the future.
- Emit Bourne-shell compatible code to set up environment variables.
- Print the version of dbus-launch
Please send bug reports to the D-Bus mailing list or bug tracker,see http://www.freedesktop.org/software/dbus/
- AUTOMATIC LAUNCHING
This document was created byman2html,using the manual pages.