Merge branch 'dbus-1.6'
[platform/upstream/dbus.git] / doc / dbus-launch.1.xml.in
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'>
5
6 <!--  dbus&bsol;-launch manual page.
7  Copyright (C) 2003 Red Hat, Inc. -->
8
9 <refmeta>
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>
15 </refmeta>
16 <refnamediv>
17 <refname>dbus-launch</refname>
18 <refpurpose>Utility to start a message bus from a shell script</refpurpose>
19 </refnamediv>
20 <!-- body begins here -->
21 <refsynopsisdiv id='synopsis'>
22 <cmdsynopsis>
23   <command>dbus-launch</command>    <arg choice='opt'>--version </arg>
24     <arg choice='opt'>--sh-syntax </arg>
25     <arg choice='opt'>--csh-syntax </arg>
26     <arg choice='opt'>--auto-syntax </arg>
27     <arg choice='opt'>--exit-with-session </arg>
28     <arg choice='opt'>--autolaunch=<replaceable>MACHINEID</replaceable></arg>
29     <arg choice='opt'>--config-file=<replaceable>FILENAME</replaceable></arg>
30     <arg choice='opt'><replaceable>PROGRAM</replaceable></arg>
31     <arg choice='opt' rep='repeat'><replaceable>ARGS</replaceable></arg>
32     <sbr/>
33 </cmdsynopsis>
34 </refsynopsisdiv>
35
36
37 <refsect1 id='description'><title>DESCRIPTION</title>
38 <para>The <command>dbus-launch</command> command is used to start a session bus
39 instance of <emphasis remap='I'>dbus-daemon</emphasis> from a shell script.
40 It would normally be called from a user's login
41 scripts. Unlike the daemon itself, <command>dbus-launch</command> exits, so
42 backticks or the $() construct can be used to read information from
43 <command>dbus-launch</command>.</para>
44
45 <para>With no arguments, <command>dbus-launch</command> will launch a session bus
46 instance and print the address and PID of that instance to standard
47 output.</para>
48
49 <para>You may specify a program to be run; in this case, <command>dbus-launch</command>
50 will launch a session bus instance, set the appropriate environment
51 variables so the specified program can find the bus, and then execute the
52 specified program, with the specified arguments.  See below for
53 examples.</para>
54
55 <para>If you launch a program, <command>dbus-launch</command> will not print the
56 information about the new bus to standard output.</para>
57
58 <para>When <command>dbus-launch</command> prints bus information to standard output, by
59 default it is in a simple key-value pairs format. However, you may
60 request several alternate syntaxes using the --sh-syntax, --csh-syntax,
61 --binary-syntax, or
62 --auto-syntax options. Several of these cause <command>dbus-launch</command> to emit shell code
63 to set up the environment.</para>
64
65 <para>With the --auto-syntax option, <command>dbus-launch</command> looks at the value
66 of the SHELL environment variable to determine which shell syntax
67 should be used.  If SHELL ends in "csh", then csh-compatible code is
68 emitted; otherwise Bourne shell code is emitted.  Instead of passing
69 --auto-syntax, you may explicitly specify a particular one by using
70 --sh-syntax for Bourne syntax, or --csh-syntax for csh syntax.
71 In scripts, it's more robust to avoid --auto-syntax and you hopefully
72 know which shell your script is written in.</para>
73
74
75 <para>See <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information
76 about D-Bus. See also the man page for <emphasis remap='I'>dbus-daemon</emphasis>.</para>
77
78 </refsect1>
79
80 <refsect1 id='examples'><title>EXAMPLES</title>
81 <para>Distributions running
82 <command>dbus-launch</command>
83 as part of a standard X session should run
84 <emphasis remap='B'>dbus-launch --exit-with-session</emphasis>
85 after the X server has started and become available, as a wrapper around
86 the "main" X client (typically a session manager or window manager), as in
87 these examples:</para>
88
89   <blockquote remap='RS'>
90 <para><emphasis remap='B'>dbus-launch --exit-with-session gnome-session</emphasis></para>
91
92 <para><emphasis remap='B'>dbus-launch --exit-with-session openbox</emphasis></para>
93
94 <para><emphasis remap='B'>dbus-launch --exit-with-session ~/.xsession</emphasis>
95   </para></blockquote> <!-- remap='RE' -->
96
97 <para>If your distribution does not do this, you can achieve similar results
98 by running your session or window manager in the same way in a script
99 run by your X session, such as
100 <filename>~/.xsession</filename>,
101 <filename>~/.xinitrc</filename>
102 or
103 <filename>~/.Xclients</filename>.</para>
104
105 <para>To start a D-Bus session within a text\(hymode session,
106   do not use <emphasis remap='B'>dbus-launch</emphasis>.
107   Instead, see <citerefentry><refentrytitle>dbus-run-session</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
108 </para>
109
110 <literallayout remap='.nf'>
111   ## test for an existing bus daemon, just to be safe
112   if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
113       ## if not found, launch a new one
114       eval `dbus-launch --sh-syntax`
115       echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
116   fi
117 </literallayout> <!-- .fi -->
118 <para>Note that in this case, dbus-launch will exit, and dbus-daemon will not be
119 terminated automatically on logout.</para>
120
121 </refsect1>
122
123 <refsect1 id='automatic_launching'><title>AUTOMATIC LAUNCHING</title>
124 <para>If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use
125 D-Bus, by default the process will attempt to invoke dbus-launch with
126 the --autolaunch option to start up a new session bus or find the
127 existing bus address on the X display or in a file in
128 ~/.dbus/session-bus/</para>
129
130
131 <para>Whenever an autolaunch occurs, the application that had to
132 start a new bus will be in its own little world; it can effectively
133 end up starting a whole new session if it tries to use a lot of
134 bus services. This can be suboptimal or even totally broken, depending
135 on the app and what it tries to do.</para>
136
137
138 <para>There are two common reasons for autolaunch. One is ssh to a remote
139 machine. The ideal fix for that would be forwarding of
140 DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded.
141 In the meantime, you can edit the session.conf config file to
142 have your session bus listen on TCP, and manually set
143 DBUS_SESSION_BUS_ADDRESS, if you like.</para>
144
145
146 <para>The second common reason for autolaunch is an su to another user, and
147 display of X applications running as the second user on the display
148 belonging to the first user. Perhaps the ideal fix in this case
149 would be to allow the second user to connect to the session bus of the
150 first user, just as they can connect to the first user's display.
151 However, a mechanism for that has not been coded.</para>
152
153
154 <para>You can always avoid autolaunch by manually setting
155 DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default
156 address if none is set is "autolaunch:", so if any other address is
157 set there will be no autolaunch. You can however include autolaunch in
158 an explicit session bus address as a fallback, for example
159 DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if
160 the first address doesn't work, processes will autolaunch. (The bus
161 address variable contains a comma-separated list of addresses to try.)</para>
162
163
164 <para>The --autolaunch option is considered an internal implementation
165 detail of libdbus, and in fact there are plans to change it. There's
166 no real reason to use it outside of the libdbus implementation anyhow.</para>
167
168 </refsect1>
169
170 <refsect1 id='options'><title>OPTIONS</title>
171 <para>The following options are supported:</para>
172 <variablelist remap='TP'>
173   <varlistentry>
174   <term><option>--auto-syntax</option></term>
175   <listitem>
176 <para>Choose --csh-syntax or --sh-syntax based on the SHELL environment variable.</para>
177
178 <para><option>--binary-syntax</option>
179 Write to stdout a nul-terminated bus address, then the bus PID as a
180 binary integer of size sizeof(pid_t), then the bus X window ID as a
181 binary integer of size sizeof(long). Integers are in the machine's
182 byte order, not network byte order or any other canonical byte order.</para>
183
184   </listitem>
185   </varlistentry>
186   <varlistentry>
187   <term><option>--close-stderr</option></term>
188   <listitem>
189 <para>Close the standard error output stream before starting the D-Bus
190 daemon. This is useful if you want to capture dbus-launch error
191 messages but you don't want dbus-daemon to keep the stream open to
192 your application.</para>
193
194   </listitem>
195   </varlistentry>
196   <varlistentry>
197   <term><option>--config-file=FILENAME</option></term>
198   <listitem>
199 <para>Pass --config-file=FILENAME to the bus daemon, instead of passing it
200 the --session argument. See the man page for dbus-daemon</para>
201
202   </listitem>
203   </varlistentry>
204   <varlistentry>
205   <term><option>--csh-syntax</option></term>
206   <listitem>
207 <para>Emit csh compatible code to set up environment variables.</para>
208
209   </listitem>
210   </varlistentry>
211   <varlistentry>
212   <term><option>--exit-with-session</option></term>
213   <listitem>
214 <para>If this option is provided, a persistent "babysitter" process will be
215 created that watches stdin for HUP and tries to connect to the X
216 server. If this process gets a HUP on stdin or loses its X connection,
217 it kills the message bus daemon.</para>
218
219   </listitem>
220   </varlistentry>
221   <varlistentry>
222   <term><option>--autolaunch=MACHINEID</option></term>
223   <listitem>
224 <para>This option implies that <command>dbus-launch</command> should scan for a
225 previously-started session and reuse the values found there. If no
226 session is found, it will start a new session. The
227 --exit-with-session option is implied if --autolaunch is given.
228 This option is for the exclusive use of libdbus, you do not want to
229 use it manually. It may change in the future.</para>
230
231   </listitem>
232   </varlistentry>
233   <varlistentry>
234   <term><option>--sh-syntax</option></term>
235   <listitem>
236 <para>Emit Bourne-shell compatible code to set up environment variables.</para>
237
238   </listitem>
239   </varlistentry>
240   <varlistentry>
241   <term><option>--version</option></term>
242   <listitem>
243 <para>Print the version of dbus-launch</para>
244
245   </listitem>
246   </varlistentry>
247 </variablelist>
248 </refsect1>
249
250 <refsect1 id='notes'><title>NOTES</title>
251 <para>If you run
252 <emphasis remap='B'>dbus-launch myapp</emphasis>
253 (with any other options), dbus-daemon will
254 <emphasis remap='I'>not</emphasis>
255 exit when
256 <emphasis remap='B'>myapp</emphasis>
257 terminates: this is because
258 <emphasis remap='B'>myapp</emphasis>
259 is assumed to be part of a larger session, rather than a session in its
260 own right.</para>
261
262 </refsect1>
263
264 <refsect1 id='author'><title>AUTHOR</title>
265 <para>See <ulink url='http://www.freedesktop.org/software/dbus/doc/AUTHORS'>http://www.freedesktop.org/software/dbus/doc/AUTHORS</ulink></para>
266
267 </refsect1>
268
269 <refsect1 id='bugs'><title>BUGS</title>
270 <para>Please send bug reports to the D-Bus mailing list or bug tracker,
271 see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
272 </refsect1>
273 </refentry>