dbus/SOURCES/ssh-x-forwarding.sh

26 lines
744 B
Bash
Raw Permalink Normal View History

2021-03-30 14:47:32 +00:00
# DBus session bus over SSH with X11 forwarding
[ -z "$SSH_CONNECTION" ] && return
2023-09-27 12:49:16 +00:00
[ -z "$XDG_SESSION_ID" ] && return
2021-03-30 14:47:32 +00:00
[ -z "$DISPLAY" ] && return
2022-03-29 18:10:38 +00:00
[ "${DISPLAY:0:1}" = ":" ] && return
[ "$SHLVL" -ne 1 ] && return
2021-03-30 14:47:32 +00:00
2023-09-27 12:49:16 +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-03-29 18:10:38 +00:00
export GDK_BACKEND=x11
eval `dbus-launch --sh-syntax`
[ -z "$DBUS_SESSION_BUS_PID" ] && return
2023-09-27 12:49:16 +00:00
mkdir -p "${DBUS_SESSIONS}"
echo "${DBUS_SESSION_BUS_ADDRESS}" > "${DBUS_SESSION_ADDRESS_FILE}"
2022-03-29 18:10:38 +00:00
setsid -f /usr/libexec/dbus-1/dbus-kill-process-with-session "$DBUS_SESSION_BUS_PID"