Loop runner_manage menu until the user cancels

This commit is contained in:
the-sane 2020-12-27 15:40:54 -05:00 committed by GitHub
parent c12509bc0c
commit 6d7c84c8b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -642,7 +642,7 @@ rm_vidcache() {
# Restart lutris # Restart lutris
lutris_restart() { lutris_restart() {
if [ "$runners_modified" = "true" ]; then if [ "$lutris_needs_restart" = "true" ]; then
if message question "Lutris must be restarted to detect runner changes.\nWould you like this helper to restart it for you?"; then if message question "Lutris must be restarted to detect runner changes.\nWould you like this helper to restart it for you?"; then
if [ "$(pgrep lutris)" ]; then if [ "$(pgrep lutris)" ]; then
echo -e "\nRestarting Lutris...\n" echo -e "\nRestarting Lutris...\n"
@ -650,6 +650,7 @@ lutris_restart() {
else else
message info "Lutris does not appear to be running." message info "Lutris does not appear to be running."
fi fi
lutris_needs_restart="false"
fi fi
fi fi
} }
@ -667,7 +668,7 @@ runner_delete() {
if message question "Are you sure you want to delete the following runner?\n\n${installed_runners[$runner_to_delete]}"; then if message question "Are you sure you want to delete the following runner?\n\n${installed_runners[$runner_to_delete]}"; then
rm -r "${installed_runners[$runner_to_delete]}" rm -r "${installed_runners[$runner_to_delete]}"
echo -e "\nDeleted ${installed_runners[$runner_to_delete]}\n" echo -e "\nDeleted ${installed_runners[$runner_to_delete]}\n"
runners_modified="true" lutris_needs_restart="true"
fi fi
} }
@ -697,7 +698,7 @@ runner_select_delete() {
# Complete the menu by adding the option to go back to the previous menu # Complete the menu by adding the option to go back to the previous menu
menu_options+=("$goback") menu_options+=("$goback")
menu_actions+=("runner_manage") menu_actions+=(":") # no-op
# Call the menu function. It will use the options as configured above # Call the menu function. It will use the options as configured above
menu menu
@ -729,12 +730,12 @@ runner_install() {
# Runners without a subdirectory in the archive # Runners without a subdirectory in the archive
echo -e "\nDownloading $runner_url\ninto $runner_dir/$runner_name\n" echo -e "\nDownloading $runner_url\ninto $runner_dir/$runner_name\n"
mkdir -p "$runner_dir/$runner_name" && curl -L "$runner_url" | tar -xzf - -C "$runner_dir/$runner_name" mkdir -p "$runner_dir/$runner_name" && curl -L "$runner_url" | tar -xzf - -C "$runner_dir/$runner_name"
runners_modified="true" lutris_needs_restart="true"
else else
# Runners with a subdirectory in the archive # Runners with a subdirectory in the archive
echo -e "\nDownloading $runner_url\ninto $runner_dir\n" echo -e "\nDownloading $runner_url\ninto $runner_dir\n"
mkdir -p "$runner_dir" && curl -L "$runner_url" | tar -xzf - -C "$runner_dir" mkdir -p "$runner_dir" && curl -L "$runner_url" | tar -xzf - -C "$runner_dir"
runners_modified="true" lutris_needs_restart="true"
fi fi
} }
@ -797,37 +798,50 @@ runner_select_install() {
# Complete the menu by adding the option to go back to the previous menu # Complete the menu by adding the option to go back to the previous menu
menu_options+=("$goback") menu_options+=("$goback")
menu_actions+=("runner_manage") menu_actions+=(":") # no-op
# Call the menu function. It will use the options as configured above # Call the menu function. It will use the options as configured above
menu menu
} }
# Called when the user is done managing runners. Causes a return to the main menu
runner_manage_done() {
managing_runners="false"
}
# Manage Lutris runners # Manage Lutris runners
runner_manage() { runner_manage() {
# Check if Lutris is installed # Check if Lutris is installed
if [ ! -x "$(command -v lutris)" ]; then if [ ! -x "$(command -v lutris)" ]; then
message info "Lutris does not appear to be installed." message info "Lutris does not appear to be installed."
return 1 return 0
fi fi
# Configure the menu # The runner management menu will loop until the user cancels
menu_text_zenity="<b>This helper can manage your Lutris runners</b>\n\nChoose from the following options:" managing_runners="true"
menu_text_terminal="This helper can manage your Lutris runners<\n\nChoose from the following options:"
menu_height="200"
# Configure the menu options while [ "$managing_runners" = "true" ]; do
rawfox="Install a runner from RawFox" # Configure the menu
snatella="Install a runner from Molotov/Snatella" menu_text_zenity="<b>This helper can manage your Lutris runners</b>\n\nChoose from the following options:"
delete="Delete an installed runner" menu_text_terminal="This helper can manage your Lutris runners<\n\nChoose from the following options:"
back="Return to the main menu" menu_height="200"
# Set the options to be displayed in the menu
menu_options=("$rawfox" "$snatella" "$delete" "$back")
# Set the corresponding functions to be called for each of the options
menu_actions=("runner_select_install rawfox" "runner_select_install snatella" "runner_select_delete" "lutris_restart")
# Call the menu function. It will use the options as configured above # Configure the menu options
menu rawfox="Install a runner from RawFox"
snatella="Install a runner from Molotov/Snatella"
delete="Delete an installed runner"
back="Return to the main menu"
# Set the options to be displayed in the menu
menu_options=("$rawfox" "$snatella" "$delete" "$back")
# Set the corresponding functions to be called for each of the options
menu_actions=("runner_select_install rawfox" "runner_select_install snatella" "runner_select_delete" "runner_manage_done")
# Call the menu function. It will use the options as configured above
menu
done
# Check if lutris needs to be restarted after making changes
lutris_restart
} }
# Toggle between targeting the LIVE and PTU game directories for all helper functions # Toggle between targeting the LIVE and PTU game directories for all helper functions
@ -861,7 +875,7 @@ fi
# Set some defaults # Set some defaults
live_or_ptu="LIVE" live_or_ptu="LIVE"
runners_modified="false" lutris_needs_restart="false"
# Loop the main menu until the user selects quit # Loop the main menu until the user selects quit
while true; do while true; do