#!/bin/bash
PIS_SBIN="${PIS_SBIN:-/sbin}"
if [ -z "${PIS_LIBDIR:-}" ]; then
    case "$(uname -m)" in x86_64) PIS_LIBDIR=/usr/lib64/pis ;; *) PIS_LIBDIR=/usr/lib/pis ;; esac
fi
. "$PIS_LIBDIR/pis_lib" 2>/dev/null || . "$(dirname "$0")/pis_lib" || exit 1
pis_init || exit 1
choice=$(dialog --stdout --backtitle "$PIS_BACKTITLE" --title "Login Mode" \
    --menu "Select the login mode. Current: $(pis_state_read login)" 0 0 0 \
    CLI "Command Line Interface (runlevel 3)" \
    GUI "Graphical User Interface (runlevel 4)") || exit 0
if pis_apply_login_mode "$choice"; then
    pis_info "Login Mode" "The login mode was set to '$choice'. It will take effect after reboot."
else
    pis_error "The login mode could not be changed."
    exit 1
fi
