1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4 <refentry id='dbuslaunch1'>
6 <!-- dbus\-launch manual page.
7 Copyright (C) 2003 Red Hat, Inc. -->
10 <refentrytitle>dbus-launch</refentrytitle>
11 <manvolnum>1</manvolnum>
12 <refmiscinfo class="manual">User Commands</refmiscinfo>
13 <refmiscinfo class="source">D-Bus</refmiscinfo>
14 <refmiscinfo class="version">@DBUS_VERSION@</refmiscinfo>
17 <refname>dbus-launch</refname>
18 <refpurpose>Utility to start a message bus from a shell script</refpurpose>
20 <!-- body begins here -->
21 <refsynopsisdiv id='synopsis'>
23 <command>dbus-launch</command>
24 <arg choice='opt'>--version </arg>
25 <arg choice='opt'>--help </arg>
26 <arg choice='opt'>--sh-syntax </arg>
27 <arg choice='opt'>--csh-syntax </arg>
28 <arg choice='opt'>--auto-syntax </arg>
29 <arg choice='opt'>--binary-syntax </arg>
30 <arg choice='opt'>--close-stderr </arg>
31 <arg choice='opt'>--exit-with-session </arg>
32 <arg choice='opt'>--autolaunch=<replaceable>MACHINEID</replaceable></arg>
33 <arg choice='opt'>--config-file=<replaceable>FILENAME</replaceable></arg>
34 <arg choice='opt'><replaceable>PROGRAM</replaceable></arg>
35 <arg choice='opt' rep='repeat'><replaceable>ARGS</replaceable></arg>
41 <refsect1 id='description'><title>DESCRIPTION</title>
42 <para>The <command>dbus-launch</command> command is used to start a session bus
43 instance of <emphasis remap='I'>dbus-daemon</emphasis> from a shell script.
44 It would normally be called from a user's login
45 scripts. Unlike the daemon itself, <command>dbus-launch</command> exits, so
46 backticks or the $() construct can be used to read information from
47 <command>dbus-launch</command>.</para>
49 <para>With no arguments, <command>dbus-launch</command> will launch a session bus
50 instance and print the address and PID of that instance to standard
53 <para>You may specify a program to be run; in this case, <command>dbus-launch</command>
54 will launch a session bus instance, set the appropriate environment
55 variables so the specified program can find the bus, and then execute the
56 specified program, with the specified arguments. See below for
59 <para>If you launch a program, <command>dbus-launch</command> will not print the
60 information about the new bus to standard output.</para>
62 <para>When <command>dbus-launch</command> prints bus information to standard output, by
63 default it is in a simple key-value pairs format. However, you may
64 request several alternate syntaxes using the --sh-syntax, --csh-syntax,
66 --auto-syntax options. Several of these cause <command>dbus-launch</command> to emit shell code
67 to set up the environment.</para>
69 <para>With the --auto-syntax option, <command>dbus-launch</command> looks at the value
70 of the SHELL environment variable to determine which shell syntax
71 should be used. If SHELL ends in "csh", then csh-compatible code is
72 emitted; otherwise Bourne shell code is emitted. Instead of passing
73 --auto-syntax, you may explicitly specify a particular one by using
74 --sh-syntax for Bourne syntax, or --csh-syntax for csh syntax.
75 In scripts, it's more robust to avoid --auto-syntax and you hopefully
76 know which shell your script is written in.</para>
79 <para>See <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information
80 about D-Bus. See also the man page for <emphasis remap='I'>dbus-daemon</emphasis>.</para>
84 <refsect1 id='examples'><title>EXAMPLES</title>
85 <para>Distributions running
86 <command>dbus-launch</command>
87 as part of a standard X session should run
88 <emphasis remap='B'>dbus-launch --exit-with-session</emphasis>
89 after the X server has started and become available, as a wrapper around
90 the "main" X client (typically a session manager or window manager), as in
91 these examples:</para>
93 <blockquote remap='RS'>
94 <para><emphasis remap='B'>dbus-launch --exit-with-session gnome-session</emphasis></para>
96 <para><emphasis remap='B'>dbus-launch --exit-with-session openbox</emphasis></para>
98 <para><emphasis remap='B'>dbus-launch --exit-with-session ~/.xsession</emphasis>
99 </para></blockquote> <!-- remap='RE' -->
101 <para>If your distribution does not do this, you can achieve similar results
102 by running your session or window manager in the same way in a script
103 run by your X session, such as
104 <filename>~/.xsession</filename>,
105 <filename>~/.xinitrc</filename>
107 <filename>~/.Xclients</filename>.</para>
109 <para>To start a D-Bus session within a text-mode session,
110 do not use <emphasis remap='B'>dbus-launch</emphasis>.
111 Instead, see <citerefentry><refentrytitle>dbus-run-session</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
114 <literallayout remap='.nf'>
115 ## test for an existing bus daemon, just to be safe
116 if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
117 ## if not found, launch a new one
118 eval `dbus-launch --sh-syntax`
119 echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
121 </literallayout> <!-- .fi -->
122 <para>Note that in this case, dbus-launch will exit, and dbus-daemon will not be
123 terminated automatically on logout.</para>
127 <refsect1 id='automatic_launching'><title>AUTOMATIC LAUNCHING</title>
128 <para>If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use
129 D-Bus, by default the process will attempt to invoke dbus-launch with
130 the --autolaunch option to start up a new session bus or find the
131 existing bus address on the X display or in a file in
132 ~/.dbus/session-bus/</para>
135 <para>Whenever an autolaunch occurs, the application that had to
136 start a new bus will be in its own little world; it can effectively
137 end up starting a whole new session if it tries to use a lot of
138 bus services. This can be suboptimal or even totally broken, depending
139 on the app and what it tries to do.</para>
142 <para>There are two common reasons for autolaunch. One is ssh to a remote
143 machine. The ideal fix for that would be forwarding of
144 DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded.
145 In the meantime, you can edit the session.conf config file to
146 have your session bus listen on TCP, and manually set
147 DBUS_SESSION_BUS_ADDRESS, if you like.</para>
150 <para>The second common reason for autolaunch is an su to another user, and
151 display of X applications running as the second user on the display
152 belonging to the first user. Perhaps the ideal fix in this case
153 would be to allow the second user to connect to the session bus of the
154 first user, just as they can connect to the first user's display.
155 However, a mechanism for that has not been coded.</para>
158 <para>You can always avoid autolaunch by manually setting
159 DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default
160 address if none is set is "autolaunch:", so if any other address is
161 set there will be no autolaunch. You can however include autolaunch in
162 an explicit session bus address as a fallback, for example
163 DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if
164 the first address doesn't work, processes will autolaunch. (The bus
165 address variable contains a comma-separated list of addresses to try.)</para>
168 <para>The --autolaunch option is considered an internal implementation
169 detail of libdbus, and in fact there are plans to change it. There's
170 no real reason to use it outside of the libdbus implementation anyhow.</para>
174 <refsect1 id='options'><title>OPTIONS</title>
175 <para>The following options are supported:</para>
176 <variablelist remap='TP'>
178 <term><option>--auto-syntax</option></term>
180 <para>Choose --csh-syntax or --sh-syntax based on the SHELL environment variable.</para>
185 <term><option>--binary-syntax</option></term>
187 <para>Write to stdout a nul-terminated bus address, then the bus PID as a
188 binary integer of size sizeof(pid_t), then the bus X window ID as a
189 binary integer of size sizeof(long). Integers are in the machine's
190 byte order, not network byte order or any other canonical byte order.</para>
195 <term><option>--close-stderr</option></term>
197 <para>Close the standard error output stream before starting the D-Bus
198 daemon. This is useful if you want to capture dbus-launch error
199 messages but you don't want dbus-daemon to keep the stream open to
200 your application.</para>
205 <term><option>--config-file=FILENAME</option></term>
207 <para>Pass --config-file=FILENAME to the bus daemon, instead of passing it
208 the --session argument. See the man page for dbus-daemon</para>
213 <term><option>--csh-syntax</option></term>
215 <para>Emit csh compatible code to set up environment variables.</para>
220 <term><option>--exit-with-session</option></term>
222 <para>If this option is provided, a persistent "babysitter" process will be
223 created that watches stdin for HUP and tries to connect to the X
224 server. If this process gets a HUP on stdin or loses its X connection,
225 it kills the message bus daemon.</para>
230 <term><option>--autolaunch=MACHINEID</option></term>
232 <para>This option implies that <command>dbus-launch</command> should scan for a
233 previously-started session and reuse the values found there. If no
234 session is found, it will start a new session. The
235 --exit-with-session option is implied if --autolaunch is given.
236 This option is for the exclusive use of libdbus, you do not want to
237 use it manually. It may change in the future.</para>
242 <term><option>--sh-syntax</option></term>
244 <para>Emit Bourne-shell compatible code to set up environment variables.</para>
249 <term><option>--version</option></term>
251 <para>Print the version of dbus-launch</para>
256 <term><option>--help</option></term>
258 <para>Print the help info of dbus-launch</para>
265 <refsect1 id='notes'><title>NOTES</title>
267 <emphasis remap='B'>dbus-launch myapp</emphasis>
268 (with any other options), dbus-daemon will
269 <emphasis remap='I'>not</emphasis>
271 <emphasis remap='B'>myapp</emphasis>
272 terminates: this is because
273 <emphasis remap='B'>myapp</emphasis>
274 is assumed to be part of a larger session, rather than a session in its
279 <refsect1 id='author'><title>AUTHOR</title>
280 <para>See <ulink url='http://www.freedesktop.org/software/dbus/doc/AUTHORS'>http://www.freedesktop.org/software/dbus/doc/AUTHORS</ulink></para>
284 <refsect1 id='bugs'><title>BUGS</title>
285 <para>Please send bug reports to the D-Bus mailing list or bug tracker,
286 see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>