#!/bin/sh

if ! busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
     org.freedesktop.login1.Manager ScheduledShutdown 2>/dev/null; then
  # If we can not determine the scheduled shutdown time we are probably
  # already at shutdown and should not startup anything.
  exit 1
fi

SYSSESSIONDIR=/etc/X11/Xsession.d
SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
if [ -n "$SESSIONFILES" ]; then
  for SESSIONFILE in $SESSIONFILES; do
    . $SESSIONFILE
  done
fi

exec "$@"
