1DBUS-LAUNCH(1)                   User Commands                  DBUS-LAUNCH(1)
2
3
4

NAME

6       dbus-launch - Utility to start a message bus from a shell script
7

SYNOPSIS

9       dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax]
10                   [--auto-syntax] [--binary-syntax] [--close-stderr]
11                   [--exit-with-session] [--autolaunch=MACHINEID]
12                   [--config-file=FILENAME] [PROGRAM] [ARGS...]
13
14

DESCRIPTION

16       The dbus-launch command is used to start a session bus instance of
17       dbus-daemon from a shell script. It would normally be called from a
18       user's login scripts. Unlike the daemon itself, dbus-launch exits, so
19       backticks or the $() construct can be used to read information from
20       dbus-launch.
21
22       With no arguments, dbus-launch will launch a session bus instance and
23       print the address and PID of that instance to standard output.
24
25       If the environment variable HOME is set, it is used as the current
26       working directory. Otherwise, the root directory (/) is used.
27
28       You may specify a program to be run; in this case, dbus-launch will
29       launch a session bus instance, set the appropriate environment
30       variables so the specified program can find the bus, and then execute
31       the specified program, with the specified arguments. See below for
32       examples.
33
34       If you launch a program, dbus-launch will not print the information
35       about the new bus to standard output.
36
37       When dbus-launch prints bus information to standard output, by default
38       it is in a simple key-value pairs format. However, you may request
39       several alternate syntaxes using the --sh-syntax, --csh-syntax,
40       --binary-syntax, or --auto-syntax options. Several of these cause
41       dbus-launch to emit shell code to set up the environment.
42
43       With the --auto-syntax option, dbus-launch looks at the value of the
44       SHELL environment variable to determine which shell syntax should be
45       used. If SHELL ends in "csh", then csh-compatible code is emitted;
46       otherwise Bourne shell code is emitted. Instead of passing
47       --auto-syntax, you may explicitly specify a particular one by using
48       --sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. In
49       scripts, it's more robust to avoid --auto-syntax and you hopefully know
50       which shell your script is written in.
51
52       See http://www.freedesktop.org/software/dbus/ for more information
53       about D-Bus. See also the man page for dbus-daemon.
54

EXAMPLES

56       Distributions running dbus-launch as part of a standard X session
57       should run dbus-launch --exit-with-session after the X server has
58       started and become available, as a wrapper around the "main" X client
59       (typically a session manager or window manager), as in these examples:
60
61       dbus-launch --exit-with-session gnome-session
62
63       dbus-launch --exit-with-session openbox
64
65       dbus-launch --exit-with-session ~/.xsession
66
67       If your distribution does not do this, you can achieve similar results
68       by running your session or window manager in the same way in a script
69       run by your X session, such as ~/.xsession, ~/.xinitrc or ~/.Xclients.
70
71       To start a D-Bus session within a text-mode session, do not use
72       dbus-launch. Instead, see dbus-run-session(1).
73
74             ## test for an existing bus daemon, just to be safe
75             if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
76                 ## if not found, launch a new one
77                 eval `dbus-launch --sh-syntax`
78                 echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
79             fi
80
81       Note that in this case, dbus-launch will exit, and dbus-daemon will not
82       be terminated automatically on logout.
83

AUTOMATIC LAUNCHING

85       If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use
86       D-Bus, by default the process will attempt to invoke dbus-launch with
87       the --autolaunch option to start up a new session bus or find the
88       existing bus address on the X display or in a file in
89       ~/.dbus/session-bus/
90
91       Whenever an autolaunch occurs, the application that had to start a new
92       bus will be in its own little world; it can effectively end up starting
93       a whole new session if it tries to use a lot of bus services. This can
94       be suboptimal or even totally broken, depending on the app and what it
95       tries to do.
96
97       There are two common reasons for autolaunch. One is ssh to a remote
98       machine. The ideal fix for that would be forwarding of
99       DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. In
100       the meantime, you can edit the session.conf config file to have your
101       session bus listen on TCP, and manually set DBUS_SESSION_BUS_ADDRESS,
102       if you like.
103
104       The second common reason for autolaunch is an su to another user, and
105       display of X applications running as the second user on the display
106       belonging to the first user. Perhaps the ideal fix in this case would
107       be to allow the second user to connect to the session bus of the first
108       user, just as they can connect to the first user's display. However, a
109       mechanism for that has not been coded.
110
111       You can always avoid autolaunch by manually setting
112       DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default
113       address if none is set is "autolaunch:", so if any other address is set
114       there will be no autolaunch. You can however include autolaunch in an
115       explicit session bus address as a fallback, for example
116       DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if the
117       first address doesn't work, processes will autolaunch. (The bus address
118       variable contains a comma-separated list of addresses to try.)
119
120       The --autolaunch option is considered an internal implementation detail
121       of libdbus, and in fact there are plans to change it. There's no real
122       reason to use it outside of the libdbus implementation anyhow.
123

OPTIONS

125       The following options are supported:
126
127       --auto-syntax
128           Choose --csh-syntax or --sh-syntax based on the SHELL environment
129           variable.
130
131       --binary-syntax
132           Write to stdout a nul-terminated bus address, then the bus PID as a
133           binary integer of size sizeof(pid_t), then the bus X window ID as a
134           binary integer of size sizeof(long). Integers are in the machine's
135           byte order, not network byte order or any other canonical byte
136           order.
137
138       --close-stderr
139           Close the standard error output stream before starting the D-Bus
140           daemon. This is useful if you want to capture dbus-launch error
141           messages but you don't want dbus-daemon to keep the stream open to
142           your application.
143
144       --config-file=FILENAME
145           Pass --config-file=FILENAME to the bus daemon, instead of passing
146           it the --session argument. See the man page for dbus-daemon
147
148       --csh-syntax
149           Emit csh compatible code to set up environment variables.
150
151       --exit-with-session
152           If this option is provided, a persistent "babysitter" process will
153           be created that watches stdin for HUP and tries to connect to the X
154           server. If this process gets a HUP on stdin or loses its X
155           connection, it kills the message bus daemon.
156
157       --autolaunch=MACHINEID
158           This option implies that dbus-launch should scan for a
159           previously-started session and reuse the values found there. If no
160           session is found, it will start a new session. The
161           --exit-with-session option is implied if --autolaunch is given.
162           This option is for the exclusive use of libdbus, you do not want to
163           use it manually. It may change in the future.
164
165       --sh-syntax
166           Emit Bourne-shell compatible code to set up environment variables.
167
168       --version
169           Print the version of dbus-launch
170
171       --help
172           Print the help info of dbus-launch
173

NOTES

175       If you run dbus-launch myapp (with any other options), dbus-daemon will
176       not exit when myapp terminates: this is because myapp is assumed to be
177       part of a larger session, rather than a session in its own right.
178

AUTHOR

180       See http://www.freedesktop.org/software/dbus/doc/AUTHORS
181

BUGS

183       Please send bug reports to the D-Bus mailing list or bug tracker, see
184       http://www.freedesktop.org/software/dbus/
185
186
187
188D-Bus 1.10.24                     03/14/2019                    DBUS-LAUNCH(1)
Impressum