functionalize launcher

This commit is contained in:
Tobias Powalowski 2023-07-14 08:13:04 +02:00
parent 074ec78ac5
commit 1a46b130c9

View file

@ -48,31 +48,9 @@ _check_manage() {
update | grep -q image && _MANAGE+=( "IMAGE" "Create New Archboot Images" )
}
_dolauncher() {
_MENU=()
if [[ -n "${_DESKTOP[@]}" ]]; then
_MENU+=( "2" "Launch Desktop Environment" )
fi
if [[ -n "${_MANAGE[@]}" ]]; then
_MENU+=( "3" "Manage Archboot Environment" )
fi
_dialog --title " Main Menu " --menu "" 10 40 6 \
"1" "Launch Archboot Setup" \
"${_MENU[@]}" \
"4" "Exit Program" 2>${_ANSWER}
case $(cat ${_ANSWER}) in
"1")
_desktop () {
_dialog --title " Desktop Menu " --menu "" 10 40 6 "${_DESKTOP[@]}" 2>${_ANSWER} || _launcher
[[ -e /tmp/.launcher-running ]] && rm /tmp/.launcher-running
setup
exit 0 ;;
"2")
_ABORT=""
_dialog --title " Desktop Menu " --menu "" 10 40 6 "${_DESKTOP[@]}" 2>${_ANSWER} || _ABORT=1
[[ -e /tmp/.launcher-running ]] && rm /tmp/.launcher-running
if [[ -n "${_ABORT}" ]]; then
clear
exit 1
fi
_EXIT="$(cat ${_ANSWER})"
if [[ "${_EXIT}" == "GNOME" ]]; then
if _dialog --defaultno --yesno "Gnome Desktop:\nDo you want to use the Wayland Backend?" 6 45; then
@ -98,10 +76,10 @@ _dolauncher() {
update -xfce
fi
exit 0
;;
"3")
_ABORT=""
_dialog --title " Manage Archboot Menu " --menu "" 9 50 5 "${_MANAGE[@]}" 2>${_ANSWER} || _ABORT=1
}
_manage() {
_dialog --title " Manage Archboot Menu " --menu "" 9 50 5 "${_MANAGE[@]}" 2>${_ANSWER} || _launcher
clear
[[ -e /tmp/.launcher-running ]] && rm /tmp/.launcher-running
if [[ -n "${_ABORT}" ]]; then
@ -120,13 +98,14 @@ _dolauncher() {
update -latest-image
fi
exit 0
;;
"4")
}
_exit() {
#shellcheck disable=SC2086
_dialog --title " EXIT MENU " --menu "" 9 30 5 \
"1" "Exit Program" \
"2" "Reboot System" \
"3" "Poweroff System" 2>${_ANSWER}
"3" "Poweroff System" 2>${_ANSWER} || _launcher
_EXIT="$(cat ${_ANSWER})"
if [[ "${_EXIT}" == "1" ]]; then
return 0
@ -141,6 +120,33 @@ _dolauncher() {
clear
poweroff
fi
}
_launcher() {
_MENU=()
if [[ -n "${_DESKTOP[@]}" ]]; then
_MENU+=( "2" "Launch Desktop Environment" )
fi
if [[ -n "${_MANAGE[@]}" ]]; then
_MENU+=( "3" "Manage Archboot Environment" )
fi
_dialog --title " Main Menu " --menu "" 10 40 6 \
"1" "Launch Archboot Setup" \
"${_MENU[@]}" \
"4" "Exit Program" 2>${_ANSWER}
case $(cat ${_ANSWER}) in
"1")
[[ -e /tmp/.launcher-running ]] && rm /tmp/.launcher-running
setup
exit 0 ;;
"2")
_desktop
;;
"3")
_manage
;;
"4")
_exit
;;
*)
if _dialog --yesno "Abort Program?" 6 40; then
@ -159,7 +165,7 @@ fi
: >/tmp/.launcher-running
_check_desktop
_check_manage
if ! _dolauncher; then
if ! _launcher; then
_show_login
exit 1
fi