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