Linux command
dbus-launch 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start a D-Bus session
dbus-launch
Start session and export
eval $(dbus-launch --sh-syntax)
Start with auto-launch
dbus-launch --autolaunch=[machine-id]
Start a specific program
dbus-launch [program] [arguments]
Exit when program terminates
dbus-launch --exit-with-session [program]
Close bus when X session
dbus-launch --exit-with-x11
说明
dbus-launch starts a session instance of the D-Bus message bus daemon and provides the connection address to client applications. It's typically used to ensure a D-Bus session is available for desktop applications. When invoked without arguments, it prints environment variables (DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID) that clients need to connect. With shell syntax options, the output can be directly evaluated to set these variables. When a program is specified, dbus-launch starts the D-Bus daemon, sets up the environment, and then executes the program. The --exit-with-session flag ensures the daemon terminates when the program exits.
参数
- --sh-syntax
- Output Bourne shell compatible syntax.
- --csh-syntax
- Output C shell compatible syntax.
- --auto-syntax
- Detect shell type from SHELL variable and use appropriate syntax.
- --binary-syntax
- Output bus address and PID in binary format.
- --autolaunch _MACHINEID_
- Enable autolaunch with specified machine ID.
- --exit-with-session
- Exit when launched program terminates.
- --exit-with-x11
- Exit when X11 connection closes.
- --close-stderr
- Close stderr before starting the daemon.
- --config-file _FILE_
- Use specified configuration file instead of --session.
- --version
- Print the version of dbus-launch.
FAQ
What is the dbus-launch command used for?
dbus-launch starts a session instance of the D-Bus message bus daemon and provides the connection address to client applications. It's typically used to ensure a D-Bus session is available for desktop applications. When invoked without arguments, it prints environment variables (DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID) that clients need to connect. With shell syntax options, the output can be directly evaluated to set these variables. When a program is specified, dbus-launch starts the D-Bus daemon, sets up the environment, and then executes the program. The --exit-with-session flag ensures the daemon terminates when the program exits.
How do I run a basic dbus-launch example?
Run `dbus-launch` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --sh-syntax do in dbus-launch?
Output Bourne shell compatible syntax.