RetroDECK/tools/configurator.sh

551 lines
18 KiB
Bash
Raw Normal View History

#!/bin/bash
2022-10-07 17:46:48 +00:00
# VARIABLES SECTION
#rd_conf="retrodeck.cfg" # uncomment for standalone testing
#source functions.sh # uncomment for standalone testing
2022-10-12 20:06:17 +00:00
source /app/libexec/global.sh # uncomment for flatpak testing
source /app/libexec/functions.sh # uncomment for flatpak testing
2022-10-07 17:46:48 +00:00
# DIALOG SECTION
# Configurator Option Tree
# Welcome
2022-11-20 21:09:13 +00:00
# - Move RetroDECK data directory
# - Migrate everything
2022-10-07 17:46:48 +00:00
# - Change Emulator Options
# - RetroArch
# - Change Rewind Setting
# - RetroAchivement login
2022-10-07 17:46:48 +00:00
# - Login prompt
# - Reset RetroDECK
2022-10-07 17:46:48 +00:00
# - Reset RetroArch
2022-10-12 20:06:17 +00:00
# - Reset Specific Standalone Emulator
2022-12-31 16:37:12 +00:00
# - Reset Citra
2022-10-12 20:06:17 +00:00
# - Reset Dolphin
2022-12-31 16:37:12 +00:00
# - Reset Duckstation
2022-10-12 20:06:17 +00:00
# - Reset MelonDS
2022-12-31 16:37:12 +00:00
# - Reset PCSX2
# - Reset PPSSPP
# - Reset Primehack
2022-10-12 20:06:17 +00:00
# - Reset RPCS3
2022-12-09 18:37:02 +00:00
# - Reset Ryujinx
2022-10-12 20:06:17 +00:00
# - Reset XEMU
2022-12-31 16:37:12 +00:00
# - Reset Yuzu
2022-10-12 20:06:17 +00:00
# - Reset All Standalone Emulators
2022-10-07 17:46:48 +00:00
# - Reset Tools
# - Reset All
2022-10-07 17:46:48 +00:00
# Code for the menus should be put in reverse order, so functions for sub-menus exists before it is called by the parent menu
2022-10-12 20:06:17 +00:00
# DIALOG TREE FUNCTIONS
2022-10-07 17:46:48 +00:00
configurator_reset_dialog() {
choice=$(zenity --list --title="RetroDECK Configurator Utility - Reset Options" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--column="Choice" --column="Action" \
"Reset RetroArch" "Reset RetroArch to default settings" \
"Reset Specific Standalone" "Reset only one specific standalone emulator to default settings" \
"Reset All Standalones" "Reset all standalone emulators to default settings" \
"Reset Tools" "Reset Tools menu entries" \
"Reset All" "Reset RetroDECK to default settings" )
case $choice in
"Reset RetroArch" )
2022-11-19 20:47:49 +00:00
ra_init
configurator_process_complete_dialog "resetting RetroArch"
;;
2022-10-07 17:46:48 +00:00
"Reset Specific Standalone" )
emulator_to_reset=$(zenity --list \
--title "RetroDECK Configurator Utility - Reset Specific Standalone Emulator" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--text="Which emulator do you want to reset to default?" \
2022-10-07 17:46:48 +00:00
--hide-header \
--column=emulator \
"RetroArch" \
"Citra" \
"Dolphin" \
"Duckstation" \
"MelonDS" \
"PCSX2" \
2022-10-07 17:46:48 +00:00
"PPSSPP" \
2022-12-31 16:37:12 +00:00
"Primehack" \
2022-12-09 14:35:39 +00:00
"RPCS3" \
2022-10-07 17:46:48 +00:00
"XEMU" \
2022-10-12 20:06:17 +00:00
"Yuzu")
2022-10-07 17:46:48 +00:00
case $emulator_to_reset in
2022-10-07 17:46:48 +00:00
"RetroArch" )
2022-11-19 20:47:49 +00:00
ra_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-07 17:46:48 +00:00
"Citra" )
2022-11-19 20:47:49 +00:00
citra_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"Dolphin" )
2022-11-19 20:47:49 +00:00
dolphin_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"Duckstation" )
2022-11-19 20:47:49 +00:00
duckstation_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"MelonDS" )
2022-11-19 20:47:49 +00:00
melonds_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
"PCSX2" )
2022-11-19 20:47:49 +00:00
pcsx2_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"PPSSPP" )
2022-11-19 20:47:49 +00:00
ppssppsdl_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-12-31 16:37:12 +00:00
"Primehack" )
primehack_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-12-09 18:37:02 +00:00
"RPCS3" )
rpcs3_init
2022-12-09 09:10:56 +00:00
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-07 17:46:48 +00:00
"XEMU" )
2022-11-19 20:47:49 +00:00
xemu_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"Yuzu" )
2022-11-19 20:47:49 +00:00
yuzu_init
configurator_process_complete_dialog "resetting $emulator_to_reset"
;;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"" ) # No selection made or Back button clicked
configurator_reset_dialog
;;
2022-10-07 17:46:48 +00:00
esac
;;
"Reset All Standalones" )
2022-11-19 20:47:49 +00:00
standalones_init
configurator_process_complete_dialog "resetting standalone emulators"
;;
"Reset Tools" )
2022-11-19 20:47:49 +00:00
tools_init
configurator_process_complete_dialog "resetting the tools menu"
;;
"Reset All" )
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Reset RetroDECK" \
--text="You are resetting RetroDECK to its default state.\n\nAfter the process is complete you will need to exit RetroDECK and run it again."
2022-11-19 20:47:49 +00:00
rm -f "$lockfile"
configurator_process_complete_dialog "resetting RetroDECK"
;;
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
;;
esac
}
configurator_retroachivement_dialog() {
2022-11-19 20:47:49 +00:00
login=$(zenity --forms --title="RetroDECK Configurator Utility - RetroArch RetroAchievements Login" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
2022-11-19 20:47:49 +00:00
--text="Enter your RetroAchievements Account details.\n\nBe aware that this tool cannot verify your login details and currently only supports logging in with RetroArch.\nFor registration and more info visit\nhttps://retroachievements.org/\n" \
--separator="=SEP=" \
--add-entry="Username" \
--add-password="Password")
if [ $? == 0 ]; then # OK button clicked
arrIN=(${login//=SEP=/ })
user=${arrIN[0]}
pass=${arrIN[1]}
set_setting_value $raconf cheevos_enable true retroarch
set_setting_value $raconf cheevos_username $user retroarch
set_setting_value $raconf cheevos_password $pass retroarch
configurator_process_complete_dialog "logging in to RetroArch RetroAchievements"
else
configurator_welcome_dialog
fi
}
configurator_update_dialog() {
configurator_generic_dialog "This feature is not available yet"
configurator_welcome_dialog
}
configurator_power_user_changes_dialog() {
zenity --title "RetroDECK Configurator Utility - Power User Options" --question --no-wrap --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
2022-11-18 20:15:59 +00:00
--text="Making manual changes to an emulators configuration may create serious issues,\nand some settings may be overwitten during RetroDECK updates.\n\nSome standalone emulator functions may not work properly outside of Desktop mode.\n\nPlease continue only if you know what you're doing.\n\nDo you want to continue?"
if [ $? == 0 ]; then # OK button clicked
emulator=$(zenity --list \
--title "RetroDECK Configurator Utility - Power User Options" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--text="Which emulator do you want to configure?" \
--hide-header \
--column=emulator \
"RetroArch" \
"Citra" \
"Dolphin" \
"Duckstation" \
"MelonDS" \
"PCSX2" \
"PPSSPP" \
2022-12-31 16:37:12 +00:00
"Primehack" \
"RPCS3" \
"XEMU" \
"Yuzu")
case $emulator in
"RetroArch" )
retroarch
;;
"Citra" )
citra-qt
;;
"Dolphin" )
dolphin-emu
;;
"Duckstation" )
duckstation-qt
;;
"MelonDS" )
melonDS
;;
"PCSX2" )
pcsx2-qt
;;
"PPSSPP" )
PPSSPPSDL
;;
2022-12-31 16:37:12 +00:00
"Primehack" )
primehack-wrapper
;;
"RPCS3" )
rpcs3
;;
"XEMU" )
xemu
;;
"Yuzu" )
yuzu
;;
"" ) # No selection made or Back button clicked
configurator_options_dialog
;;
esac
else
configurator_options_dialog
fi
}
2022-10-07 20:28:36 +00:00
configurator_retroarch_rewind_dialog() {
if [[ $(get_setting_value $raconf rewind_enable retroarch) == "true" ]]; then
zenity --question \
--no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator - Rewind" \
--text="Rewind is currently enabled. Do you want to disable it?."
if [ $? == 0 ]
then
set_setting_value $raconf "rewind_enable" "false" retroarch
configurator_process_complete_dialog "disabling Rewind"
2022-10-07 20:28:36 +00:00
else
configurator_options_dialog
2022-10-07 17:46:48 +00:00
fi
else
zenity --question \
--no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator - Rewind" \
--text="Rewind is currently disabled, do you want to enable it?\n\nNOTE:\nThis may impact performance expecially on the latest systems."
if [ $? == 0 ]
then
set_setting_value $raconf "rewind_enable" "true" retroarch
configurator_process_complete_dialog "enabling Rewind"
else
configurator_options_dialog
fi
fi
2022-10-07 17:46:48 +00:00
}
2022-10-07 20:28:36 +00:00
configurator_retroarch_options_dialog() {
choice=$(zenity --list --title="RetroDECK Configurator Utility - RetroArch Options" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--column="Choice" --column="Action" \
"Change Rewind Setting" "Enable or disable the Rewind function in RetroArch" )
2022-10-07 20:28:36 +00:00
case $choice in
2022-10-07 20:28:36 +00:00
"Change Rewind Setting" )
configurator_retroarch_rewind_dialog
;;
2022-10-07 20:28:36 +00:00
"" ) # No selection made or Back button clicked
configurator_options_dialog
;;
2022-10-12 20:06:17 +00:00
esac
2022-10-07 20:28:36 +00:00
}
2022-10-07 17:46:48 +00:00
configurator_options_dialog() {
choice=$(zenity --list --title="RetroDECK Configurator Utility - Change Options" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--column="Choice" --column="Action" \
"Change RetroArch Settings" "Change settings specific to RetroArch" \
"Power User Changes" "Make changes directly in an emulator" )
2022-10-07 17:46:48 +00:00
case $choice in
2022-10-07 17:46:48 +00:00
"Change RetroArch Settings" )
configurator_retroarch_options_dialog
;;
2022-10-07 17:46:48 +00:00
"Power User Changes" )
configurator_power_user_changes_dialog
;;
2022-10-07 17:46:48 +00:00
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
;;
2022-10-12 20:06:17 +00:00
esac
2022-10-07 17:46:48 +00:00
}
2022-10-10 21:01:19 +00:00
configurator_move_dialog() {
if [[ -d $rdhome ]]; then
destination=$(configurator_destination_choice_dialog "RetroDECK Data" "Please choose a destination for the RetroDECK data folder.")
case $destination in
2022-11-20 21:09:13 +00:00
"Back" )
configurator_move_dialog
;;
2022-11-20 21:09:13 +00:00
"Internal Storage" )
2022-11-20 21:09:13 +00:00
if [[ ! -L "$HOME/retrodeck" && -d "$HOME/retrodeck" ]]; then
configurator_generic_dialog "The RetroDECK data folder is already at that location, please pick a new one."
configurator_move_dialog
else
configurator_generic_dialog "Moving RetroDECK data folder to $destination"
2022-11-20 21:09:13 +00:00
unlink $HOME/retrodeck # Remove symlink for $rdhome
move $rdhome "$HOME"
if [[ ! -d $rdhome && -d $HOME/retrodeck ]]; then # If the move succeeded
rdhome="$HOME/retrodeck"
roms_folder="$rdhome/roms"
saves_folder="$rdhome/saves"
states_folder="$rdhome/states"
bios_folder="$rdhome/bios"
media_folder="$rdhome/downloaded_media"
themes_folder="$rdhome/themes"
emulators_post_move
2022-11-20 21:09:13 +00:00
conf_write
configurator_process_complete_dialog "moving the RetroDECK data directory to internal storage"
else
configurator_generic_dialog "The moving process was not completed, please try again."
fi
fi
;;
2022-11-20 21:09:13 +00:00
"SD Card" )
2022-11-21 19:02:19 +00:00
if [[ -L "$HOME/retrodeck" && -d "$sdcard/retrodeck" && "$rdhome" == "$sdcard/retrodeck" ]]; then
configurator_generic_dialog "The RetroDECK data folder is already configured to that location, please pick a new one."
configurator_move_dialog
else
if [[ ! -w $sdcard ]]; then
configurator_generic_dialog "The SD card was found but is not writable\nThis can happen with cards formatted on PC or for other reasons.\nPlease format the SD card through the Steam Deck's Game Mode and try the moving process again."
configurator_welcome_dialog
else
2022-11-20 21:09:13 +00:00
if [[ $(verify_space $rdhome $sdcard) == "true" ]];then
configurator_generic_dialog "Moving RetroDECK data folder to $destination"
if [[ -L "$HOME/retrodeck/roms" ]]; then # Check for ROMs symlink user may have created
unlink "$HOME/retrodeck/roms"
2022-11-20 21:09:13 +00:00
fi
unlink $HOME/retrodeck # Remove symlink for $rdhome
2022-11-20 21:09:13 +00:00
(
dir_prep "$sdcard/retrodeck" "$rdhome"
2022-11-20 21:09:13 +00:00
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Move in Progress" \
--text="Moving directory $rdhome to new location of $sdcard/retrodeck, please wait."
2022-11-21 19:02:19 +00:00
if [[ -L $rdhome && ! $rdhome == "$HOME/retrodeck" ]]; then # Clean up extraneus symlinks from previous moves
unlink $rdhome
fi
if [[ ! -L "$HOME/retrodeck" ]]; then # Always link back to original directory
2022-12-31 15:29:13 +00:00
ln -svf "$sdcard/retrodeck" "$HOME"
2022-11-21 19:02:19 +00:00
fi
2022-11-20 21:09:13 +00:00
rdhome="$sdcard/retrodeck"
roms_folder="$rdhome/roms"
saves_folder="$rdhome/saves"
states_folder="$rdhome/states"
bios_folder="$rdhome/bios"
media_folder="$rdhome/downloaded_media"
themes_folder="$rdhome/themes"
emulators_post_move
2022-11-20 21:09:13 +00:00
conf_write
configurator_process_complete_dialog "moving the RetroDECK data directory to SD card"
else
zenity --icon-name=net.retrodeck.retrodeck --error --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Move Directories" \
--text="The destination directory you have selected does not have enough free space for the files you are trying to move.\n\nPlease select a new destination or free up some space."
fi
fi
fi
;;
"Custom Location" )
configurator_generic_dialog "Select the root folder you would like to store the RetroDECK data folder in.\n\nA new folder \"retrodeck\" will be created in the destination chosen."
custom_dest=$(browse "RetroDECK directory location")
if [[ ! -w $custom_dest ]]; then
2023-01-10 16:42:55 +00:00
configurator_generic_dialog "The destination was found but is not writable\n\nThis can happen if RetroDECK does not have permission to write to this location.\n\nThis can typically be solved through the utility Flatseal, please make the needed changes and try the moving process again."
2022-11-20 21:09:13 +00:00
configurator_welcome_dialog
else
if [[ $(verify_space $rdhome $custom_dest) ]];then
configurator_generic_dialog "Moving RetroDECK data folder to $custom_dest/retrodeck"
if [[ -L $rdhome/roms ]]; then # Check for ROMs symlink user may have created
2022-11-20 21:09:13 +00:00
unlink $rdhome/roms
fi
unlink $HOME/retrodeck # Remove symlink for $rdhome if the previous location was not internal
2022-11-20 21:09:13 +00:00
(
dir_prep "$custom_dest/retrodeck" "$rdhome"
2022-11-20 21:09:13 +00:00
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Move in Progress" \
--text="Moving directory $rdhome to new location of $custom_dest/retrodeck, please wait."
2022-11-21 19:02:19 +00:00
if [[ ! -L "$HOME/retrodeck" ]]; then
2022-12-31 15:29:13 +00:00
ln -svf "$custom_dest/retrodeck" "$HOME"
2022-11-21 19:02:19 +00:00
fi
if [[ -L $rdhome && ! $rdhome == "$HOME/retrodeck" ]]; then # Clean up extraneus symlinks from previous moves
unlink $rdhome
fi
2022-11-20 21:09:13 +00:00
rdhome="$custom_dest/retrodeck"
roms_folder="$rdhome/roms"
saves_folder="$rdhome/saves"
states_folder="$rdhome/states"
bios_folder="$rdhome/bios"
media_folder="$rdhome/downloaded_media"
themes_folder="$rdhome/themes"
emulators_post_move
2022-11-19 20:47:49 +00:00
conf_write
configurator_process_complete_dialog "moving the RetroDECK data directory to SD card"
2022-11-20 21:09:13 +00:00
else
zenity --icon-name=net.retrodeck.retrodeck --error --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Move Directories" \
--text="The destination directory you have selected does not have enough free space for the files you are trying to move.\n\nPlease select a new destination or free up some space."
fi
fi
;;
2022-10-10 21:01:19 +00:00
esac
else
configurator_generic_dialog "The RetroDECK data folder was not found at the expected location.\n\nThis may have happened if the folder was moved manually.\n\nPlease select the current location of the RetroDECK data folder."
2022-11-19 20:47:49 +00:00
rdhome=$(browse "RetroDECK directory location")
2022-11-20 21:09:13 +00:00
roms_folder="$rdhome/roms"
saves_folder="$rdhome/saves"
states_folder="$rdhome/states"
bios_folder="$rdhome/bios"
media_folder="$rdhome/downloaded_media"
themes_folder="$rdhome/themes"
emulator_post_move
2022-11-19 20:47:49 +00:00
conf_write
configurator_generic_dialog "RetroDECK data folder now configured at $rdhome. Please start the moving process again."
configurator_move_dialog
fi
2022-10-07 17:46:48 +00:00
}
configurator_welcome_dialog() {
# Clear the variables
source=
destination=
action=
setting=
setting_value=
choice=$(zenity --list --title="RetroDECK Configurator Utility" --cancel-label="Quit" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--column="Choice" --column="Action" \
"Move Files" "Move files between internal/SD card or to custom locations" \
"Change Options" "Adjust how RetroDECK behaves" \
"RetroAchivements" "Log in to RetroAchievements" \
"Reset" "Reset parts of RetroDECK" )
case $choice in
"Move Files" )
configurator_generic_dialog "This option will move the RetroDECK data folder (ROMs, saves, BIOS etc.) to a new location.\n\nPlease choose where to move the RetroDECK data folder."
configurator_move_dialog
;;
"Change Options" )
configurator_options_dialog
;;
"RetroAchivements" )
configurator_retroachivement_dialog
;;
"Reset" )
configurator_reset_dialog
;;
"Quit" )
exit 0
;;
esac
2022-10-07 17:46:48 +00:00
}
# START THE CONFIGURATOR
2022-10-07 17:46:48 +00:00
configurator_welcome_dialog