#!/bin/bash

readonly conf=/etc/calamares-config-switcher.conf

if [[ -f "${conf}" ]]; then
    # shellcheck source=/etc/calamares-config-switcher.conf
    . "${conf}"
fi

title=${title:-"Switcher"}
text=${text:-"Select:"}
if [[ -z "${configs[*]}" ]]; then
    configs=(offline online)
fi

select=$(kdialog --title "${title}" --combobox "${text}" "${configs[@]}" --default "${configs[0]}") || exit 1

pkexec ln -snf /etc/calamares-"$select" /etc/calamares
pkexec calamares "$@"
