*NAME*

dbus-launch - Utility to start a message bus from a shell script
dbus-launch - 从shell脚本启动一个消息总线的工具(实用程序)

URL

http://dbus.freedesktop.org/doc/dbus-launch.1.html

SYNOPSIS

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

DESCRIPTION

The dbus-launch command is used to start a session bus instance of dbus-daemon from a shell script.
dbus-launch 命令用于从shell脚本启动一个 dbus-daemon 的会话总线实例.
It would normally be called from a user's login scripts.
dbus-launch 命令通常会在用户的登录脚本中调用.
Unlike the daemon itself, dbus-launch exits, so backticks or the \(() construct can be used to read information from dbus-launch. 与守护进程不同, 如果 dbus-launch 退出, 那么可以使用反引号或者\)()结构从dbus-launch中读取信息.

With no arguments, dbus-launch will launch a session bus instance and print the address and pid of that instance to standard output.
如果没有参数, dbus-launch 会加载一个会话总线实例,并且把地址和实例的pid打印到标准输出.

You may specify a program to be run; in this case,
dbus-launch will launch a session bus instance,
你可以指定一个程序运行; 在这种情况下, dbus-launch 会加载一个会话实例,
set the appropriate environment variables so the specified program can find the bus,
and then execute the specified program, with the specified arguments. See below for examples.
并且设置恰当的环境变量使指定的程序能够找到总线,并且之后使用指定的参数来执行指定的程序.
看下面的例子作为参考.

If you launch a program, dbus-launch will not print the information about the new bus to standard output.
如果你加载一个程序, dbus-launch 不会在标准输出打印新总线的信息.

When dbus-launch prints bus information to standard output,
by default it is in a simple key-value pairs format.
当dbus-launch在标准输出打印bus信息时, 默认情况下是简单的key-value pairs格式.
However, you may request several alternate syntaxes using the --sh-syntax,
--csh-syntax, --binary-syntax, or --auto-syntax options.
当然, 你可以请求几个可替换的语法 通过使用--sh-syntax, --csh-syntax, --binary-syntax, 或者 --auto-syntax 选项.
Several of these cause dbus-launch to emit shell code to set up the environment.
其中几个会引起dbus-launch发送shell code来设置环境.

With the --auto-syntax option, dbus-launch looks at the value of the SHELL environment variable
to determine which shell syntax should be used.
使用--auto-syntax 选项, dbus-launch 会根据SHELL环境变量来决定使用哪一个shell语法.

If SHELL ends in "csh", then csh-compatible code is emitted; otherwise Bourne shell code is emitted.
如果SHELL 以"csh" 结尾, 那么会发送 csh-compatible code; 否则会发送Bourne shell code.
Instead of passing --auto-syntax, you may explicity specify a particular one
by using --sh-syntax for Bourne syntax, or --csh-syntax for csh syntax.
如果不使用 --auto-syntax选项, 你可以明确的指定一个,
--sh-syntax for Bourne syntax, or --csh-syntax for csh syntax.

In scripts, it's more robust to avoid --auto-syntax and you hopefully know which shell your script is written in.
在脚本中, 避免使用 --auto-syntax 会增加脚本的健壮性,并且你也希望知道你的脚本写在什么shell中.

See http://www.freedesktop.org/software/dbus/ for more information about D-Bus.
See also the man page for dbus-daemon.

EXAMPLES

Here is an example of how to use dbus-launch with an sh-compatible shell to start the per-session bus daemon:
下面是一个如何使用dbus-launch的例子, 使用一个sh-compatible shell来启动每会话总线守护进程:

## test for an existing bus daemon, just to be safe (测试是否存在总线守护进程)
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
## if not found, launch a new one
eval `dbus-launch --sh-syntax --exit-with-session`
echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
fi

You might run something like that in your login scripts.
你可以在你的登录脚本中运行类似的命令.

Note that in this case, dbus-launch will exit, and dbus-daemon will not be terminated automatically on logout.

在这个例子中,需要注意的是dbus-launch会退出,但是dbus-daemon在登出会自动结束.

Another way to use dbus-launch is to run your main session program, like so:
另一种使用dbus-launch的方法是运行你的主会话程序, 像下面这样:

Distributions running dbus-launch as part of a standard X session should run dbus-launch --exit-with-session after the X server has started and become available, as a wrapper around the "main" X client (typically a session manager or window manager), as in these examples:

dbus-launch --exit-with-session gnome-sessiondbus-launch --exit-with-session openboxdbus-launch --exit-with-session ~/.xsession

The above would likely be appropriate for ~/.xsession or ~/.Xclients.
上面的用法应当在 ~/.xsession 和 ~/.Xclients 文件中使用.

If your distribution does not do this, you can achieve similar results by running your session or window manager in the same way in a script run by your X session, such as ~/.xsession,~/.xinitrc or ~/.Xclients.

AUTOMATIC LAUNCHING

If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use D-Bus,
如果没有为一个要使用D-Bus的进程设置 DBUS_SESSION_BUS_ADDRESS,
by default the process will attempt to invoke dbus-launch with the --autolaunch option to start up a new session bus
默认情况下,这个进程会试图使用--autolaunch选项执行dbus-launch来启动一个新的会话,
or find the existing bus address on the X display or in a file in ~/.dbus/session-bus/
或者寻找在X display上或目录(~/.dbus/session-bus/)下文件中 存在的总线地址.

Whenever an autolaunch occurs, the application that had to start a new bus will be in its own little world;
每当一个autolaunch发生,需要启动一个新总线的应用会在自己的小世界中;
it can effectively end up starting a whole new session if it tries to use a lot of bus services.
如果应用想要使用很多的总线服务,这种方式有效的启动一个全新的会话.
This can be suboptimal or even totally broken, depending on the app and what it tries to do.
这种方式是次优甚至毁灭性的, 这取决于app和他想要做什么.

There are two common reasons for autolaunch.
使用autolaunch有2个通常的原因.
One is ssh to a remote machine.
一个是ssh来远程计算机.
The ideal fix for that would be forwarding of DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded.
In the meantime, you can edit the session.conf config file to have your session bus listen on TCP,
在此期间, 你可以编辑 session.conf 配置文件来使你的session bus 监听TCP,
and manually set DBUS_SESSION_BUS_ADDRESS, if you like.
如果你愿意,你可以手动设置 DBUS_SESSION_BUS_ADDRESS.

The second common reason for autolaunch is an su to another user,
第二个原因是超级用户对于另一个用户,
and display of X applications running as the second user on the display belonging to the first user.
并且X应用的显示作为第二个用户运行在属于第一个用户的的display上.
Perhaps the ideal fix in this case would be to allow the second user to connect to the session bus of the first user,
也可以这个case可能允许第二个用户连接到第一个用的会话总线上,
just as they can connect to the first user's display. However, a mechanism for that has not been coded.
就像和他可以连接到第一个用户的display上, 但是这种结构没有实现.

You can always avoid autolaunch by manually setting DBUS_SESSION_BUS_ADDRESS.
你总是可以通过手动设置DBUS_SESSION_BUS_ADDRESS来避免autolaunch.
Autolaunch happens because the default address if none is set is "autolaunch:",
Autolaunch发生是因为默认的地址中
so if any other address is set there will be no autolaunch.
所以如果设置有任何其他地址,就不会发生autolaunch.
You can however include autolaunch in an explicit session bus address as a fallback,
然而你可以在总线地址中包含autolaunch作为备选方案,
for example DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:"
in that case if the first address doesn't work, processes will autolaunch.
这种情况下,如果第一个地址不能正常工作,进程就会autolaunch.
(The bus address variable contains a comma-separated list of addresses to try.)
总线地址变量是一个使用逗号分隔的可以尝试使用的地址列表.

The --autolaunch option is considered an internal implementation detail of libdbus, and in fact there are plans to change it.
--autolaunch选项被认为是libdbus一个内部实现详细, 并且实际上计划要改变它.
There's no real reason to use it outside of the libdbus implementation anyhow.
总之没有任何原因在libdbus实现外使用 --autolaunch选项.

OPTIONS

The following options are supported:
dbus-launch命令支持下面的选项:

--auto-syntax

Choose --csh-syntax or --sh-syntax based on the SHELL environment variable.
根据环境变量SHELL的值自动选择使用--csh-syntax 或者 --sh-syntax.

--binary-syntax

Write to stdout a nul-terminated bus address,
--binary-syntax 向stdout写一个null结尾的bus地址字符串,
then the bus PID as a binary integer of size sizeof(pid_t),
跟着是总线PID,大小是sizeof(pid_t)二进制整型.
then the bus X window ID as a binary integer of size sizeof(long).
再跟着是这个总线的 X window ID,大小是sizeof(long)二进制整型.
Integers are in the machine's byte order, not network byte order or any other canonical byte order.
整形是使用机器的字节序,不是网络字节序或者其他标准的字节序.

--csh-syntax

Emit csh compatible code to set up environment variables.
发送csh兼容码设置环境变量

--sh-syntax

Emit Bourne-shell compatible code to set up environment variables.
发送Bourne-shell兼容码设置环境变量

--close-stderr

Close the standard error output stream before starting the D-Bus daemon.
启动D-Bus 守护进程前关闭标准输出流.
This is useful if you want to capture dbus-launch error messages
but you don't want dbus-daemon to keep the stream open to your application.
如果你想捕获dbus-launch错误消息,但是不想dbus-daemon保持流对对应用的开放,这会使非常有用的.

--config-file=FILENAME

Pass --config-file=FILENAME to the bus daemon, instead of passing it the --session argument.
通过将配置文件FILENAME传给 bus daemon 来代替 --session argument.
See the man page for dbus-daemon

--exit-with-session

If this option is provided, a persistent "babysitter" process will be created that watches
stdin for HUP and tries to connect to the X server.
如果提供了这个选项, 会创建一个持续的 "babysitter"进程用于监视stdin 中的 HUP信息, 并且试着连接到 X server.
If this process gets a HUP on stdin or loses its X connection, it kills the message bus daemon.
如果这个进程在stdin中获得了HUP或者丢失了他的 X connection, 他会终止消息总线的守护进程.

--autolaunch=MACHINEID

This option implies that dbus-launch should scan for a previously-started session and reuse the values found there.
这个选项意味着dbus-launch应该扫描先前启动的session并且复用在那发现的值.
If no session is found, it will start a new session.
如果没有找到会话, 他会启动一个新的会话.
The --exit-with-session option is implied if --autolaunch is given.
如果提供了--atuolaunch选项, --exit-with-session选项也默认开启.
This option is for the exclusive use of libdbus, you do not want to use it manually. It may change in the future.
这个选项是为libdbus独有的, 你不会想要手动使用这个选项.

--version

Print the version of dbus-launch

NOTES

If you run dbus-launch myapp (with any other options), dbus-daemon will not exit when myapp terminates:

this is because myapp is assumed to be part of a larger session, rather than a session in its own right.

如果你运行下面这样的指令(和其他任何选项),

dbus-launch myapp 

当myapp结束时,dbus-daemon也不会退出,这是因为myapp被认为是一个大的会话的一部分,而不是一个在自己权限中的会话.

转自:https://www.cnblogs.com/LubinLew/p/dbus_launch.html

转载于:https://www.cnblogs.com/itxdm/p/dbus-launch.html

dbus-launch(转)相关推荐

  1. DBUS学习-DBUS实例

    由 b178903294创建, 最后修改于8月 20, 2019 一.原生DBUS实例 原生dbus客户端代码和服务端代码: client.c 折叠源码 #include <stdio.h> ...

  2. Dbus启动问题 Failed to get D-Bus connection: Operation not permitted

    最近在服务器看到,abrt-action-gen服务一直在跑,且占用较多内存,经查询后发现是abrtd服务出现问题,用systemctl erestart abrtd. systemctl erest ...

  3. VS Code 配置调试参数、launch.json 配置文件属性、task.json 变量替换、自动保存并格式化、空格和制表符、函数调用关系、文件搜索和全局搜索、

    1. 生成配置参数 对于大多数的调试都需要在当前项目目录下创建一个 lanch.json 文件,位置是在当前项目目录下生成一个 .vscode 的隐藏文件夹,在里面放置一些配置内容,比如:settin ...

  4. Jenkins 2.16.3默认没有Launch agent via Java Web Start,如何配置使用

    问题:Jenkins 2.16.3默认没有Launch agent via Java Web Start,如下图所示,而这种启动方式在Windows上是最方便的. 如何设置才能让出来呢? 打开&quo ...

  5. linux+Qt 下利用D-Bus进行进程间高效通信的三种方式

    linux+Qt 下利用D-Bus进行进程间高效通信的三种方式 原文链接: https://www.cnblogs.com/wwang/archive/2010/10/27/1862552.html ...

  6. 【linux】ubuntu14.04升级dbus到1.13.8,杯具了,无法进入桌面

    一.问题描述 在ubuntu14.04中安装了Qt5.12,启动QtCreator报错,需要高版本的dbus. 将dbus升级到1.13.8后,杯具了,无法进入桌面 二.尝试解决 1.尝试恢复之前的版 ...

  7. ROS中launch文件使用笔记

    1. 常用标签 <launch> <!--根标签--> <node> <!--需要启动的node及其参数--> <include> < ...

  8. [***.launch] is neither a launch file in package [***] nor is [***] a launch

    主要原因是没有在编译后source一下 解决方法: cd ~/catkin_ws/catkin_makesource ./devel/setup.bash 重新编译之后再source一下即可解决. 参 ...

  9. 第 5 章 Nova - 030 - Launch和Shut Off操作详解

    Launch Launch instance 应该算 Nova 最重要的操作. 1.客户(可以是 OpenStack 最终用户,也可以是其他程序)向 API(nova-api)发送请求:"帮 ...

  10. webapp检测安卓app是否安装并launch

    1. cordova插件 1)查看所有已安装的安卓app https://www.npmjs.com/package/cordova-plugin-packagemanager A simple pl ...

最新文章

  1. 为什么AI感知与人类感知无法直接比较?
  2. 在eclipse中导入工程后@Override报错
  3. NoneBot2插件——打印系统状态
  4. 关闭oracle服务 linux,Linux下启动和关闭Oracle服务与数据库
  5. 你真的会写留言功能吗?
  6. 博客园今天将排名计算错误了
  7. java线程协作_java 线程间的协作
  8. IE6不能用gzip压缩脚本,一个流毒甚广的谣言
  9. mysql5.5.20安装_mysql5.5.20安装文档
  10. Java开发两年:简述jvm内存模型
  11. Django如何让未登录的用户自动跳转至登录页
  12. Spacecom:将和信威集团在30天内决定新的收购协议
  13. linux 下的绘图软件Visio
  14. 【180620】小人物走路、奔跑的VC++游戏特效
  15. windows11百度网盘下载,win11iso镜像百度云下载
  16. 机器学习SVM之SMO方法α,ω和b迭代公式的推导过程
  17. 关于浮点运算和定点运算
  18. 5G消息应用号推荐|官方种草清单第六期
  19. 智能机器人 迪姆人工_艾美迪迪姆智能故事机
  20. idea修改回默认字体_设置 IntelliJ IDEA 主题和字体的方法

热门文章

  1. XML专题:使用NSXMLParser解析xml文件
  2. 思科路由器MTU及ip tcp adjust-mss测试
  3. android launcher
  4. Android 中文API (70) —— BluetoothDevice[蓝牙]
  5. initrd映像文档的作用和制作
  6. The mountain is unchanged,but the heart is changed
  7. 【MySQL】MySQL的group_concat使用例子
  8. HTML5 geolocation和BaiduMap、BingMap、GoogleMap
  9. 升级python2.6.6到python2.7导致pip命令不可用
  10. Shader 中的随机与噪声