Blob Blame History Raw
#!/bin/bash
# This script ensures the dbus-daemon is killed when the session closes.
# It's used by SSH sessions that have X forwarding (since the X display
# may outlive the session in those cases)
[ $# != 1 ] && exit 1

exec >& /dev/null

trap 'kill -TERM $1 $(jobs -p)' EXIT

export GVFS_DISABLE_FUSE=1
coproc SESSION_MONITOR (gio monitor -f "/run/systemd/sessions/${XDG_SESSION_ID}")

while grep -q ^State=active <(loginctl show-session $XDG_SESSION_ID)
do
    read -u ${SESSION_MONITOR[0]}
done