#!/bin/sh
# Start gtkgreet in cage for greetd's default_session.
#
# cage refuses to start without XDG_RUNTIME_DIR. pam_systemd is only
# optional in greetd's PAM stack, so the greeter session can end up
# without one. Fall back to a private runtime dir from tmpfiles.
if [ -z "$XDG_RUNTIME_DIR" ]; then
    if [ -d "/run/user/$(id -u)" ]; then
        XDG_RUNTIME_DIR="/run/user/$(id -u)"
    else
        XDG_RUNTIME_DIR=/run/greeter
    fi
    export XDG_RUNTIME_DIR
fi

exec cage -s -- /usr/bin/gtkgreet "$@"
