D-Bus: Difference between revisions
m (Formatting "=" in Cmd template) |
mNo edit summary |
||
Line 14: | Line 14: | ||
{{Cmd|dbus-daemon --nofork --address unix:path{{=}}$XDG_RUNTIME_DIR/bus --session}} | {{Cmd|dbus-daemon --nofork --address unix:path{{=}}$XDG_RUNTIME_DIR/bus --session}} | ||
For the applications that dont work without <code>$DBUS_SESSION_BUS_ADDRESS</code> you can prepend your program with the follow workaround script which avoid launching multiple user dbus sessions: | |||
#!/bin/sh | |||
if [ ! -e "/tmp/dbus-$USER-env" ]; then | |||
echo "Creating new dbus session on /tmp/dbus-$USER-env" | |||
export $(dbus-launch) | |||
echo "${DBUS_SESSION_BUS_ADDRESS}" > /tmp/dbus-$USER-env | |||
echo "Dbus session address is: ${DBUS_SESSION_BUS_ADDRESS}" | |||
else | |||
echo "Using dbus session address from /tmp/dbus-$USER-env" | |||
export DBUS_SESSION_BUS_ADDRESS="$(cat /tmp/dbus-$USER-env)" | |||
echo "Dbus session address is: ${DBUS_SESSION_BUS_ADDRESS}" | |||
fi | |||
if [ -n "$1" ]; then | |||
$@ | |||
fi | |||
[[Category:System Administration]] | [[Category:System Administration]] |
Revision as of 23:52, 11 June 2023
D-Bus is a message bus system that provides a mechanism for inter-process communication.
Some services (including Pipewire) rely on a D-Bus session instance. Other processes will only be able to communicate with these services if d-bus is running.
You can start a dbus session like this: dbus-run-session -- sh
(replacing sh with your shell or a window manager), or, export $(dbus-launch)
. This is distinct from running dbus system-wide: rc-service dbus start
, which is a prerequisite to run a user dbus session.
D-Bus passes the environment variable $DBUS_SESSION_BUS_ADDRESS
to its children. Running dbus-launch
in a terminal means that other running process won't find this D-Bus's socket.
If $DBUS_SESSION_BUS_ADDRESS
is undefined, many applications will attempt to use the standard path:
$XDG_RUNTIME_DIR/bus
Running D-Bus like so should work for many applications:
dbus-daemon --nofork --address unix:path=$XDG_RUNTIME_DIR/bus --session
For the applications that dont work without $DBUS_SESSION_BUS_ADDRESS
you can prepend your program with the follow workaround script which avoid launching multiple user dbus sessions:
#!/bin/sh if [ ! -e "/tmp/dbus-$USER-env" ]; then echo "Creating new dbus session on /tmp/dbus-$USER-env" export $(dbus-launch) echo "${DBUS_SESSION_BUS_ADDRESS}" > /tmp/dbus-$USER-env echo "Dbus session address is: ${DBUS_SESSION_BUS_ADDRESS}" else echo "Using dbus session address from /tmp/dbus-$USER-env" export DBUS_SESSION_BUS_ADDRESS="$(cat /tmp/dbus-$USER-env)" echo "Dbus session address is: ${DBUS_SESSION_BUS_ADDRESS}" fi if [ -n "$1" ]; then $@ fi