Return to main menu instead of exiting

This commit is contained in:
the-sane 2020-08-14 22:33:04 -04:00 committed by GitHub
parent 095e18ef53
commit cc2e9d6c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,7 @@ message() {
# warning # warning
echo -e "\n$2\n" echo -e "\n$2\n"
read -n 1 -s -p "Press any key..." read -n 1 -s -p "Press any key..."
exit 0 return 0
elif [ "$1" -eq 3 ]; then elif [ "$1" -eq 3 ]; then
# question # question
echo -e "$2" echo -e "$2"
@ -110,8 +110,8 @@ message() {
getdirs() { getdirs() {
# Sanity checks # Sanity checks
if [ ! -d "$conf_dir" ]; then if [ ! -d "$conf_dir" ]; then
message 2 "Config directory not found. The script will now exit.\n\n$conf_dir" message 2 "Config directory not found. The script is unable to proceed.\n\n$conf_dir"
exit 0 return 1
fi fi
if [ ! -d "$conf_dir/$conf_subdir" ]; then if [ ! -d "$conf_dir/$conf_subdir" ]; then
@ -130,18 +130,19 @@ getdirs() {
fi fi
if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then
clear
message 1 "You will now be asked to provide some directories needed by this script.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/" message 1 "You will now be asked to provide some directories needed by this script.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/"
if [ "$has_zen" -eq 1 ]; then if [ "$has_zen" -eq 1 ]; then
# Get the wine prefix directory # Get the wine prefix directory
if [ -z "$wine_prefix" ]; then if [ -z "$wine_prefix" ]; then
wine_prefix="$(zenity --file-selection --directory --title="Select your WINE prefix directory" --filename="$HOME/.wine")" wine_prefix="$(zenity --file-selection --directory --title="Select your WINE prefix directory" --filename="$HOME/.wine")"
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message 2 "An unexpected error has occurred." message 2 "An unexpected error has occurred. The script is unable to proceed."
exit 0 return 1
elif [ -z "$wine_prefix" ]; then elif [ -z "$wine_prefix" ]; then
# User clicked cancel # User clicked cancel
message 2 "Operation cancelled. The script will now exit." message 2 "Operation cancelled.\nNo changes have been made to your game."
exit 0 return 1
fi fi
fi fi
@ -149,8 +150,8 @@ getdirs() {
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen LIVE directory" --filename="$wine_prefix/")"; do while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen LIVE directory" --filename="$wine_prefix/")"; do
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message 2 "An unexpected error has occurred." message 2 "An unexpected error has occurred. The script is unable to proceed."
exit 0 return 1
elif [ "$(basename "$game_path")" != "LIVE" ]; then elif [ "$(basename "$game_path")" != "LIVE" ]; then
message 2 "You must select your LIVE directory." message 2 "You must select your LIVE directory."
else else
@ -161,8 +162,8 @@ getdirs() {
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
# User clicked cancel # User clicked cancel
message 2 "Operation cancelled. The script will now exit." message 2 "Operation cancelled.\nNo changes have been made to your game."
exit 0 return 1
fi fi
fi fi
@ -170,17 +171,16 @@ getdirs() {
if [ -z "$backup_path" ]; then if [ -z "$backup_path" ]; then
backup_path="$(zenity --file-selection --directory --title="Select a backup directory for your keybinds" --filename="$HOME/")" backup_path="$(zenity --file-selection --directory --title="Select a backup directory for your keybinds" --filename="$HOME/")"
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message 2 "An unexpected error has occurred." message 2 "An unexpected error has occurred. The script is unable to proceed."
exit 0 return 1
elif [ -z "$backup_path" ]; then elif [ -z "$backup_path" ]; then
# User clicked cancel # User clicked cancel
message 2 "Operation cancelled. The script will now exit." message 2 "Operation cancelled.\nNo changes have been made to your game."
exit 0 return 1
fi fi
fi fi
else else
clear clear
# Get the wine prefix directory # Get the wine prefix directory
if [ -z "$wine_prefix" ]; then if [ -z "$wine_prefix" ]; then
echo -e "Enter the full path to your WINE prefix directory (case sensitive)" echo -e "Enter the full path to your WINE prefix directory (case sensitive)"
@ -243,11 +243,15 @@ sanitize() {
# Get/Set directory paths # Get/Set directory paths
getdirs getdirs
if [ "$?" -eq 1 ]; then
# User cancelled and wants to return to the main menu, or there was an error
return 0
fi
# Sanity check # Sanity check
if [ ! -d "$user_dir" ]; then if [ ! -d "$user_dir" ]; then
message 2 "Directory not found. The script will now exit.\n\n$user_dir" message 2 "Directory not found. The script is unable to proceed.\n\n$user_dir"
exit 0 return 0
fi fi
# Check for exported keybind files # Check for exported keybind files
@ -255,8 +259,8 @@ sanitize() {
if message 3 "Warning: No exported keybindings found. Keybinds will not be backed up!\n\nDo you want to continue anyway?"; then if message 3 "Warning: No exported keybindings found. Keybinds will not be backed up!\n\nDo you want to continue anyway?"; then
exported=0 exported=0
else else
message 2 "The script will now exit." # User said no
exit 0 return 0
fi fi
else else
exported=1 exported=1
@ -298,7 +302,7 @@ set_map_count() {
# If vm.max_map_count is already set, no need to do anything # If vm.max_map_count is already set, no need to do anything
if [ "$(cat /proc/sys/vm/max_map_count)" -ge 16777216 ]; then if [ "$(cat /proc/sys/vm/max_map_count)" -ge 16777216 ]; then
message 1 "vm.max_map_count is already set to the optimal value. You're all set!" message 1 "vm.max_map_count is already set to the optimal value. You're all set!"
exit 0 return 0
fi fi
trap check_map_count EXIT trap check_map_count EXIT
@ -307,7 +311,7 @@ set_map_count() {
if message 3 "It looks like you've already configured your system to work with Star Citizen\nand saved the setting to persist across reboots.\nHowever, for some reason the persistence part did not work.\n\nFor now, would you like to enable the setting again until the next reboot?"; then if message 3 "It looks like you've already configured your system to work with Star Citizen\nand saved the setting to persist across reboots.\nHowever, for some reason the persistence part did not work.\n\nFor now, would you like to enable the setting again until the next reboot?"; then
pkexec sh -c 'sysctl -w vm.max_map_count=16777216' pkexec sh -c 'sysctl -w vm.max_map_count=16777216'
fi fi
exit 0 return 0
fi fi
once="Change setting until next reboot" once="Change setting until next reboot"