#!/bin/sh -eu

SYSTEMCTL=systemctl
SD_BOOTED="$(PATH="/usr/sbin:/sbin:$PATH" command -v sd_booted)"
COMM=

# Check that init is systemd
if [ -z "$SD_BOOTED" ] || ! "$SD_BOOTED" >/dev/null 2>&1 || ! command -v "$SYSTEMCTL" >/dev/null 2>&1; then
	exit 0
fi

case "${1-}" in
	start) COMM="start" ;;
	stop) COMM="stop" ;;
	*) exit 1;;
esac

exec $SYSTEMCTL --user "$COMM" xfce4-session.target
