--text="Would you like to set $chosen_user as the default user?\n\nIf the current user cannot be determined from the system, the default will be used.\nThis normally only happens in Desktop Mode.\n\nIf you would like to be asked which user is playing every time, click \"No and don't ask again\"")
rc=$?# Capture return code, as "Yes" button has no text value
if[[$rc=="1"]];then# If any button other than "Yes" was clicked
configurator_generic_dialog "RetroDECK Multi-User Mode""The Steam username of the current user could not be determined from the system.\n\nThis can happen when running in Desktop mode.\n\nYou will be asked to specify the Steam username (not profile name) of the current user in the next dialog."
fi
if[[ -d "$multi_user_data_folder"&&$(ls -1 "$multi_user_data_folder"| wc -l) -gt 0]];then# If multi-user data folder exists from prior use and is not empty
if[[ -d "$multi_user_data_folder/$SteamAppUser"]];then# Current user has an existing save folder
configurator_generic_dialog "RetroDECK Multi-User Mode""The current user $SteamAppUser has an existing folder in the multi-user data folder.\n\nThe saves here are likely older than the ones currently used by RetroDECK.\n\nThe old saves will be backed up to $backups_folder and the current saves will be loaded into the multi-user data folder."
if[[ -z $default_user]];then# And a default user is not set
configurator_generic_dialog "RetroDECK Multi-User Mode""The current user could not be determined from the system, and there are multiple users registered.\n\nPlease select which user is currently playing in the next dialog."
if[[ ! -z $SteamAppUser]];then# User was chosen from dialog
multi_user_link_current_user_files
else
configurator_generic_dialog "RetroDECK Multi-User Mode""No user was chosen, RetroDECK will launch with the files from the user who played most recently."
fi
else# The default user is set
if[[ ! -z $(ls -1 $multi_user_data_folder| grep "$default_user")]];then# Confirm user data folder exists
SteamAppUser=$default_user
multi_user_link_current_user_files
else# Default user has no data folder, something may have gone horribly wrong. Setting up as a new user.
multi_user_setup_new_user
fi
fi
else# If there is only 1 user in the userlist, default to that user
SteamAppUser=$(ls -1 $multi_user_data_folder)
multi_user_link_current_user_files
fi
fi
else# If the userlist file doesn't exist yet, create it and add the current user
if[[ ! -z "$SteamAppUser"]];then
multi_user_setup_new_user
else# If running in Desktop mode for the first time
configurator_generic_dialog "RetroDECK Multi-User Mode""The current user could not be determined from the system and there is no existing userlist.\n\nPlease enter the Steam account username (not profile name) into the next dialog, or run RetroDECK in game mode."
if zenity --entry \
--title="Specify Steam username"\
--text="Enter Steam username:"
then# User clicked "OK"
SteamAppUser="$?"
if[[ ! -z "$SteamAppUser"]];then
multi_user_setup_new_user
else# But dialog box was blank
configurator_generic_dialog "RetroDECK Multi-User Mode""No username was entered, so multi-user data folder cannot be created.\n\nDisabling multi-user mode, please try the process again."
for emu_conf in $(find "/var/config" -mindepth 1 -maxdepth 1 -type d -printf '%f\n')# For all the currently non-linked config folders, like from a newly-added emulator
for emu_conf in $(find "/var/config" -mindepth 1 -maxdepth 1 -type d -printf '%f\n')# Find any new emulator config folders from last time this user played