1dbus-launch(1) General Commands Manual dbus-launch(1)
2
3
4
6 dbus-launch - Utility to start a message bus from a shell script
7
9 dbus-launch [--version] [--sh-syntax] [--csh-syntax] [--auto-syntax]
10 [--exit-with-session] [--autolaunch=MACHINEID] [--config-file=FILENAME]
11 [PROGRAM] [ARGS...]
12
13
15 The dbus-launch command is used to start a session bus instance of
16 dbus-daemon from a shell script. It would normally be called from a
17 user's login scripts. Unlike the daemon itself, dbus-launch exits, so
18 backticks or the $() construct can be used to read information from
19 dbus-launch.
20
21 With no arguments, dbus-launch will launch a session bus instance and
22 print the address and pid of that instance to standard output.
23
24 You may specify a program to be run; in this case, dbus-launch will
25 launch a session bus instance, set the appropriate environment vari‐
26 ables so the specified program can find the bus, and then execute the
27 specified program, with the specified arguments. See below for exam‐
28 ples.
29
30 If you launch a program, dbus-launch will not print the information
31 about the new bus to standard output.
32
33 When dbus-launch prints bus information to standard output, by default
34 it is in a simple key-value pairs format. However, you may request sev‐
35 eral alternate syntaxes using the --sh-syntax, --csh-syntax, --binary-
36 syntax, or --auto-syntax options. Several of these cause dbus-launch to
37 emit shell code to set up the environment.
38
39 With the --auto-syntax option, dbus-launch looks at the value of the
40 SHELL environment variable to determine which shell syntax should be
41 used. If SHELL ends in "csh", then csh-compatible code is emitted;
42 otherwise Bourne shell code is emitted. Instead of passing --auto-syn‐
43 tax, you may explicity specify a particular one by using --sh-syntax
44 for Bourne syntax, or --csh-syntax for csh syntax. In scripts, it's
45 more robust to avoid --auto-syntax and you hopefully know which shell
46 your script is written in.
47
48
49 See http://www.freedesktop.org/software/dbus/ for more information
50 about D-Bus. See also the man page for dbus-daemon.
51
52
53 Here is an example of how to use dbus-launch with an sh-compatible
54 shell to start the per-session bus daemon:
55
56 ## test for an existing bus daemon, just to be safe
57 if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
58 ## if not found, launch a new one
59 eval `dbus-launch --sh-syntax --exit-with-session`
60 echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
61 fi
62
63 You might run something like that in your login scripts.
64
65
66 Another way to use dbus-launch is to run your main session program,
67 like so:
68
69 dbus-launch gnome-session
70
71 The above would likely be appropriate for ~/.xsession or ~/.Xclients.
72
73
75 If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use
76 D-Bus, by default the process will attempt to invoke dbus-launch with
77 the --autolaunch option to start up a new session bus or find the
78 existing bus address on the X display or in a file in ~/.dbus/session-
79 bus/
80
81
82 Whenever an autolaunch occurs, the application that had to start a new
83 bus will be in its own little world; it can effectively end up starting
84 a whole new session if it tries to use a lot of bus services. This can
85 be suboptimal or even totally broken, depending on the app and what it
86 tries to do.
87
88
89 There are two common reasons for autolaunch. One is ssh to a remote
90 machine. The ideal fix for that would be forwarding of DBUS_SES‐
91 SION_BUS_ADDRESS in the same way that DISPLAY is forwarded. In the
92 meantime, you can edit the session.conf config file to have your ses‐
93 sion bus listen on TCP, and manually set DBUS_SESSION_BUS_ADDRESS, if
94 you like.
95
96
97 The second common reason for autolaunch is an su to another user, and
98 display of X applications running as the second user on the display
99 belonging to the first user. Perhaps the ideal fix in this case would
100 be to allow the second user to connect to the session bus of the first
101 user, just as they can connect to the first user's display. However, a
102 mechanism for that has not been coded.
103
104
105 You can always avoid autolaunch by manually setting DBUS_SES‐
106 SION_BUS_ADDRESS. Autolaunch happens because the default address if
107 none is set is "autolaunch:", so if any other address is set there will
108 be no autolaunch. You can however include autolaunch in an explicit
109 session bus address as a fallback, for example DBUS_SES‐
110 SION_BUS_ADDRESS="something:,autolaunch:" - in that case if the first
111 address doesn't work, processes will autolaunch. (The bus address vari‐
112 able contains a comma-separated list of addresses to try.)
113
114
115 The --autolaunch option is considered an internal implementation detail
116 of libdbus, and in fact there are plans to change it. There's no real
117 reason to use it outside of the libdbus implementation anyhow.
118
119
121 The following options are supported:
122
123 --auto-syntax
124 Choose --csh-syntax or --sh-syntax based on the SHELL environ‐
125 ment variable.
126
127 --binary-syntax Write to stdout a nul-terminated bus address,
128 then the bus PID as a binary integer of size sizeof(pid_t), then
129 the bus X window ID as a binary integer of size sizeof(long).
130 Integers are in the machine's byte order, not network byte order
131 or any other canonical byte order.
132
133
134 --close-stderr
135 Close the standard error output stream before starting the D-Bus
136 daemon. This is useful if you want to capture dbus-launch error
137 messages but you don't want dbus-daemon to keep the stream open
138 to your application.
139
140
141 --config-file=FILENAME
142 Pass --config-file=FILENAME to the bus daemon, instead of pass‐
143 ing it the --session argument. See the man page for dbus-daemon
144
145
146 --csh-syntax
147 Emit csh compatible code to set up environment variables.
148
149
150 --exit-with-session
151 If this option is provided, a persistent "babysitter" process
152 will be created that watches stdin for HUP and tries to connect
153 to the X server. If this process gets a HUP on stdin or loses
154 its X connection, it kills the message bus daemon.
155
156
157 --autolaunch=MACHINEID
158 This option implies that dbus-launch should scan for a previ‐
159 ously-started session and reuse the values found there. If no
160 session is found, it will start a new session. The --exit-with-
161 session option is implied if --autolaunch is given. This option
162 is for the exclusive use of libdbus, you do not want to use it
163 manually. It may change in the future.
164
165
166 --sh-syntax
167 Emit Bourne-shell compatible code to set up environment vari‐
168 ables.
169
170
171 --version
172 Print the version of dbus-launch
173
174
176 See http://www.freedesktop.org/software/dbus/doc/AUTHORS
177
178
180 Please send bug reports to the D-Bus mailing list or bug tracker, see
181 http://www.freedesktop.org/software/dbus/
182
183
184
185 dbus-launch(1)