2022-06-23 13:07:15 +00:00
|
|
|
# DBus session bus over SSH with X11 forwarding
|
|
|
|
[ -z "$SSH_CONNECTION" ] && return
|
2023-04-24 15:54:07 +00:00
|
|
|
[ -z "$XDG_SESSION_ID" ] && return
|
2022-06-23 13:07:15 +00:00
|
|
|
[ -z "$DISPLAY" ] && return
|
|
|
|
[ "${DISPLAY:0:1}" = ":" ] && return
|
|
|
|
[ "$SHLVL" -ne 1 ] && return
|
|
|
|
|
2023-04-24 15:54:07 +00:00
|
|
|
DBUS_SESSIONS="${XDG_RUNTIME_DIR}/dbus-1/sessions"
|
|
|
|
DBUS_SESSION_ADDRESS_FILE="${DBUS_SESSIONS}/${XDG_SESSION_ID}"
|
|
|
|
|
|
|
|
if [ -e "${DBUS_SESSION_ADDRESS_FILE}" ]; then
|
|
|
|
export DBUS_SESSION_BUS_ADDRESS="$(cat ${DBUS_SESSION_ADDRESS_FILE})"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2022-06-23 13:07:15 +00:00
|
|
|
export GDK_BACKEND=x11
|
|
|
|
|
|
|
|
eval `dbus-launch --sh-syntax`
|
|
|
|
|
|
|
|
[ -z "$DBUS_SESSION_BUS_PID" ] && return
|
2023-04-24 15:54:07 +00:00
|
|
|
|
|
|
|
mkdir -p "${DBUS_SESSIONS}"
|
|
|
|
echo "${DBUS_SESSION_BUS_ADDRESS}" > "${DBUS_SESSION_ADDRESS_FILE}"
|
|
|
|
|
2022-06-23 13:07:15 +00:00
|
|
|
setsid -f /usr/libexec/dbus-1/dbus-kill-process-with-session "$DBUS_SESSION_BUS_PID"
|