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