[Unit]
Description=Shutdown running GNOME Session

# Allow exit.target to start even if this unit is started with replace-irreversibly.
# All (weak) dependencies need to do the same. Services also need to ensure they
# are in the root slice by setting Slice=-.slice.
DefaultDependencies=no

Conflicts=graphical-session.target graphical-session-pre.target
After=graphical-session.target graphical-session-pre.target

# Add explicit conflicts/after lines for gnome-session targets, technically
# this should not be needed, but is an extra safety measure.
Conflicts=gnome-session.target gnome-session-manager.target
After=gnome-session.target gnome-session-manager.target

Conflicts=gnome-session-pre.target gnome-session-initialized.target
After=gnome-session-pre.target gnome-session-initialized.target

# We need to make sure this unit is stopped; primarily so that the tree of
# units that we created is completely cleaned.
# Note that this can also be improved by reversing the conflicts above and
# not listing them in the shutdown unit.
StopWhenUnneeded=true

# We trigger a restart of DBus after reaching the shutdown target this
# is a workaround so that DBus services that do not connect to the
# display server are shut down after log-out.
# This should be removed when the relevant services add a
# PartOf=graphical-session.target
# Historic bug: https://bugzilla.gnome.org/show_bug.cgi?id=764029
Wants=gnome-session-restart-dbus.service
Before=gnome-session-restart-dbus.service
