User Commands dbus-launch(1)
NAME
dbus-launch - Utility to start a message bus from a shell
script
SYNOPSIS
dbus-launch [--auto-syntax] [--config-file=filename] [--
close-stderr] [--csh-syntax] [--exit-with-session] [--help]
[--sh-syntax] [--version]
DESCRIPTION
The dbus-launch command is used to start a session bus
instance of dbus-daemon from a shell script. It would nor-
mally 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 launch a session bus
instance and print the address and pid of that instance to
standard output.
You may specify a program to be run; in this case, dbus-
launch will launch a session bus instance, set the appropri-
ate environment variables so the specified program can find
the bus, and then execute the specified program, with the
specified arguments. See below for examples.
If you launch a program, dbus-launch will not print the
information about the new bus to standard output.
When dbus-launch prints bus information to standard output,
by default it is in a simple key-value pairs format. How-
ever, 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
code to set up the environment.
With the --auto-syntax option, dbus-launch looks at the
value of the SHEL environment variable to determine which
shell syntax should be used. If SHEL 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 is 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. Also see the man page for dbus-
daemon.
EXTENDED DESCRIPTION
SunOS 5.11 Last change: 19 Nov 2007 1
User Commands dbus-launch(1)
AUTOMATIC LAUNCHING
If DBUSESIONBUSADRES is not set for a process that
tries to use D-Bus, by default the process will attempt to
invoke dbus-launch with the --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 to
start a new bus will be in its own little world; it can
effectively end up starting a whole new session if it tries
to use a lot of bus services. This can be suboptimal or even
totally broken, depending on the application and what it
tries to do.
There are two common reasons for autolaunch. One is ssh to a
remote machine. The ideal fix for that would be forwarding
of DBUSESIONBUSADRES 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 set DBUSESIONBUSADRES, if you like.
The second common reason for autolaunch is an su(1m). to
another user, and display of X applications running as the
second user on the display belonging to the first user.
Perhaps the ideal fix in this case would be to allow the
second user to connect to the session bus of the first user,
just as they can connect to the first user's display. How-
ever, a mechanism for that has not been coded.
You can always avoid autolaunch by manually setting
DBUSESIONBUSADRES. Autolaunch happens because the
default address (if none is set) is "autolaunch:", so if any
other address is set there will be no autolaunch. You can
however include autolaunch in an explicit session bus
address as a fallback, for example
DBUSESIONBUSADRES="something:,autolaunch:" - in that
case if the first address doesn't work, processes will auto-
launch. (The bus address variable contains a comma-separated
list of addresses to try.)
The --autolaunch option is considered an internal implemen-
tation detail of libdbus, and in fact there are plans to
change it. There is no real reason to use it outside of the
libdbus implementation anyhow.
OPTIONS
The following options are supported:
--autolaunch=machineid
This option implies that dbus-launch should scan for a
previously-started session and reuse the values found
SunOS 5.11 Last change: 19 Nov 2007 2
User Commands dbus-launch(1)
there. If no session is found, it will start a new ses-
sion. The --exit-with-session option is implied if --
autolaunch is given. This option is for the exclusive
use of libdbus, you do not want to use it manually. It
may change in the future.
--auto-syntax
Choose --csh-syntax or --sh-syntax based on the SHEL
environment variable.
--binary-syntax
Write to stdout a nul-terminated bus address, then the
bus PID as a binary integer of size sizeof(pidt), then
the bus X window ID as a binary integer of size
sizeof(long). Integers are in the machine's byte order,
not network byte order or any other canonical byte
order.
--close-stderr
Close the standard error output stream before starting
the D-Bus daemon. This is useful if you want to capture
dbus-launch error messages but you do not want
dbus-daemon to keep the stream open to your application.
--config-file=filename
Pass --config-file=filename to the bus daemon, instead
of passing it the --session argument. See the man page
for dbus-daemon.
--csh-syntax
Emit csh compatible code to set up environment vari-
ables.
--exit-with-session
SunOS 5.11 Last change: 19 Nov 2007 3
User Commands dbus-launch(1)
If this option is provided, a persistent "babysitter"
process will be created that watches stdin for HUP and
tries to connect to the X server. If this process gets
a HUP on stdin or loses its X connection, it kills the
message bus daemon.
-?, --help
Show help information on standard output and exit.
--sh-syntax
Emit Bourne-shell compatible code to set up environment
variables.
--version
Print the version of dbus-launch.
EXAMPLES
Example 1: How to use dbus-launch with a sh-compatible shell
to start the per-session bus daemon
## test for an existing bus daemon, just to be safe
if test -z "$DBUSESIONBUSADRES" ; then
## if not found, launch a new one
eval `dbus-launch --sh-syntax --exit-with-session`
echo "D-Bus per-session daemon address is: $DBUSESIONBUSADRES"
fi
Example 2: Use dbus-launch to run your main session program
example% dbus-launch --exit-with-session gnome-session
The above would likely be appropriate for ~/.xsession or
~/.Xclients.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment
variables:
DBUSESIONBUSADRES
The address of the login session message bus. If this
SunOS 5.11 Last change: 19 Nov 2007 4
User Commands dbus-launch(1)
variable is not set, applications may also try to read
the address from the X Window System root window pro-
perty DBUSESIONBUSADRES. The root window pro-
perty must have type STRING. The environment variable
should have precedence over the root window property.
DBUSVERBOSE
Set DBUSVERSION=1 to enable debugging, if D-Bus was
compiled with verbose debug mode enabled.
SHEL
When the --auto-syntax is used, then dbus-launch checks
the SHEL environment variable. If it ends in "csh",
then the --csh-syntax option will be used, otherwise the
--sh-syntax will be used.
EXIT STATUS
The following exit values are returned:
0 Application exited successfully
>0 Application exited with failure
FILES
The following files are used by this application:
/usr/bin/dbus-launch Executable for dbus-launch
/etc/dbus-1/session.conf Configuration file for D-Bus
session services.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 19 Nov 2007 5
User Commands dbus-launch(1)
ATRIBUTE TYPE ATRIBUTE VALUE
Availability SUNWdbus
Interface stability Volatile
SEE ALSO
dbus-cleanup-sockets(1), dbus-daemon(1), dbus-monitor(1),
dbus-send(1), dbus-uuidgen(1), libdbus-glib-1(3), attri-
butes(5), environ(5)
NOTES
For authorship information refer to
http:/www.freedesktop.org/software/dbus/doc/AUTHORS.
Updated by Brian Cameron, Sun Microsystems Inc., 2007.
Please send bug reports to the D-Bus mailing list or bug
tracker, see http:/www.freedesktop.org/software/dbus/
SunOS 5.11 Last change: 19 Nov 2007 6
|