# Compatibility adapter for openSUSE's legacy display-manager dispatcher.
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This file is sourced by /usr/lib/X11/display-manager.  It intentionally
# contains no service-selection policy; update-alternatives provides that.

plasmalogin_start_proc() {
    if [ -x /usr/bin/plymouth ]; then
        /usr/bin/plymouth quit
    fi
    return 0
}

plasmalogin_vars() {
    case "$1" in
        plasmalogin)
            # display-manager-legacy.service is Type=forking and expects a
            # PID file.  Upstream plasmalogin deliberately stays in the
            # foreground and does not create one, so use the compatibility
            # supervisor shipped by the legacy subpackage.
            DISPLAYMANAGER=/usr/libexec/plasmalogin-legacy-launcher
            STARTPROC=plasmalogin_start_proc

            # The legacy dispatcher defaults to SIGHUP on reload.  The
            # plasmalogin daemon does not install a SIGHUP handler, so make
            # legacy reload a safe process-existence check instead of
            # terminating the greeter.  Native plasmalogin.service has no
            # ExecReload and is unaffected.
            RELOADPROC=
            RELOADSIGNAL=-0
            ;;
        *)
            return 1
            ;;
    esac
    return 0
}
