2022-06-09 08:25:20 +00:00
#!/bin/bash
# This file is containing some global function needed for the script such as the config file tools
2022-10-24 19:49:47 +00:00
source /app/libexec/functions.sh
2022-09-06 13:24:36 +00:00
# Static variables
2023-03-10 19:22:19 +00:00
rd_conf = "/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path
rd_conf_backup = "/var/config/retrodeck/retrodeck.bak" # Backup of RetroDECK config file from update
emuconfigs = "/app/retrodeck/emu-configs" # folder with all the default emulator configs
2023-03-14 19:43:28 +00:00
rd_defaults = " $emuconfigs /defaults/retrodeck/retrodeck.cfg " # A default RetroDECK config file
2023-03-10 19:22:19 +00:00
rd_update_patch = "/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates
2023-03-17 20:39:51 +00:00
bios_checklist = " $emuconfigs /defaults/retrodeck/bios_checklist.cfg " # A config file listing BIOS file information that can be verified
2023-03-14 19:43:28 +00:00
compression_targets = " $emuconfigs /defaults/retrodeck/compression_targets.cfg " # A config file containing supported compression types per system
2023-03-17 20:39:51 +00:00
easter_egg_checklist = " $emuconfigs /defaults/retrodeck/easter_egg_checklist.cfg " # A config file listing days and times when special splash screens should show up
2023-03-20 13:23:04 +00:00
input_validation = " $emuconfigs /defaults/retrodeck/input_validation.cfg " # List of valid CLI inputs
2023-03-10 19:22:19 +00:00
splashscreen_dir = "/var/config/emulationstation/.emulationstation/resources/graphics/extra-splashes" # The default location of extra splash screens
current_splash_file = "/var/config/emulationstation/.emulationstation/resources/graphics/splash.svg" # The active splash file that will be shown on boot
default_splash_file = "/var/config/emulationstation/.emulationstation/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen
2023-03-17 20:39:51 +00:00
multi_user_data_folder = " $rdhome /multi-user-data " # The default location of multi-user environment profiles
rd_userlist = "/var/config/retrodeck/userlist.cfg" # A list of all known Steam users, for multi-user functionality
2023-03-10 19:22:19 +00:00
lockfile = "/var/config/retrodeck/.lock" # where the lockfile is located
default_sd = "/run/media/mmcblk0p1" # Steam Deck SD default path
hard_version = " $( cat '/app/retrodeck/version' ) " # hardcoded version (in the readonly filesystem)
2022-09-06 12:46:59 +00:00
2022-10-26 16:51:46 +00:00
# Config files for emulators with single config files
citraconf = "/var/config/citra-emu/qt-config.ini"
2023-02-07 13:50:04 +00:00
duckstationconf = "/var/data/duckstation/settings.ini"
2022-10-26 16:51:46 +00:00
melondsconf = "/var/config/melonDS/melonDS.ini"
rpcs3conf = "/var/config/rpcs3/config.yml"
yuzuconf = "/var/config/yuzu/qt-config.ini"
# ES-DE config files
es_settings = "/var/config/emulationstation/.emulationstation/es_settings.xml"
# RetroArch config files
raconf = "/var/config/retroarch/retroarch.cfg"
ra_core_conf = "/var/config/retroarch/retroarch-core-options.cfg"
# Dolphin config files
dolphinconf = "/var/config/dolphin-emu/Dolphin.ini"
dolphingcpadconf = "/var/config/dolphin-emu/GCPadNew.ini"
dolphingfxconf = "/var/config/dolphin-emu/GFX.ini"
dolphinhkconf = "/var/config/dolphin-emu/Hotkeys.ini"
dolphinqtconf = "/var/config/dolphin-emu/Qt.ini"
# PCSX2 config files
pcsx2conf = "/var/config/PCSX2/inis/GS.ini"
pcsx2uiconf = "/var/config/PCSX2/inis/PCSX2_ui.ini"
pcsx2vmconf = "/var/config/PCSX2/inis/PCSX2_vm.ini"
2022-11-18 20:10:17 +00:00
# PCSX2-QT config file
pcsx2qtconf = "/var/config/PCSX2/inis/PCSX2.ini"
2023-03-11 16:15:16 +00:00
# Primehack config files
primehackconf = "/var/config/primehack/Dolphin.ini"
primehackgcpadconf = "/var/config/primehack/GCPadNew.ini"
primehackgfxconf = "/var/config/primehack/GFX.ini"
primehackhkconf = "/var/config/primehack/Hotkeys.ini"
primehackqtconf = "/var/config/primehack/Qt.ini"
2022-11-18 20:10:17 +00:00
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
if [ -f " $HOME /retrodeck/.lock " ]
then
mv " $HOME /retrodeck/.lock " $lockfile
fi
2022-09-17 15:20:39 +00:00
# If there is no config file I initalize the file with the the default values
if [ ! -f " $rd_conf " ]
then
2022-10-07 06:48:35 +00:00
mkdir -p /var/config/retrodeck
2022-09-17 15:20:39 +00:00
echo " RetroDECK config file not found in $rd_conf "
echo "Initializing"
2022-10-24 19:49:47 +00:00
# if we are here means that the we are in a new installation, so the version is valorized with the hardcoded one
2022-09-19 07:25:49 +00:00
# Initializing the variables
2022-10-06 21:47:09 +00:00
if [ -z $version ] ; then
2022-11-18 20:10:17 +00:00
if [ [ $( cat $lockfile ) = = *"0.4." * ] ] || [ [ $( cat $lockfile ) = = *"0.3." * ] ] || [ [ $( cat $lockfile ) = = *"0.2." * ] ] || [ [ $( cat $lockfile ) = = *"0.1." * ] ] ; then # If the previous version is very out of date, pre-rd_conf
2022-10-24 19:49:47 +00:00
echo "Running version workaround"
version = $( cat $lockfile )
else
version = " $hard_version "
fi
2022-10-06 21:47:09 +00:00
fi
2022-10-24 19:49:47 +00:00
2022-12-22 15:34:50 +00:00
# Check if SD card path has changed from SteamOS update
if [ [ ! -d $default_sd && " $( ls -A /run/media/deck/) " ] ] ; then
configurator_generic_dialog "The SD card was not found in the expected location.\nThis may happen when SteamOS is updated.\n\nPlease browse to the current location of the SD card.\n\nIf you are not using an SD card, please click \"Cancel\"."
2023-03-07 15:06:08 +00:00
default_sd = $( directory_browse "SD Card Location" )
2022-12-22 15:34:50 +00:00
fi
2023-03-11 16:15:16 +00:00
2023-03-08 14:51:13 +00:00
cp $rd_defaults $rd_conf # Load default settings
set_setting_value $rd_conf "version" " $version " retrodeck # Set current version for new installs
set_setting_value $rd_conf "sdcard" " $default_sd " retrodeck # Set SD card location if default path has changed
2022-09-19 07:25:49 +00:00
2022-09-24 18:28:49 +00:00
echo "Setting config file permissions"
2022-10-24 19:49:47 +00:00
chmod +rw $rd_conf
2023-03-08 14:51:13 +00:00
echo "RetroDECK config file initialized. Contents:"
echo
cat $rd_conf
source $rd_conf # Load new variables into memory
2022-09-24 18:28:49 +00:00
2022-09-17 15:20:39 +00:00
# If the config file is existing i just read the variables (source it)
else
echo " Found RetroDECK config file in $rd_conf "
echo "Loading it"
source " $rd_conf "
2022-12-22 15:34:50 +00:00
2023-01-05 14:50:07 +00:00
# Verify rdhome is where it is supposed to be.
if [ [ ! -d $rdhome ] ] ; then
prev_home_path = $rdhome
configurator_generic_dialog "The RetroDECK data folder was not found in the expected location.\nThis may happen when SteamOS is updated.\n\nPlease browse to the current location of the \"retrodeck\" folder."
2023-03-07 15:06:08 +00:00
new_home_path = $( directory_browse "RetroDECK folder location" )
2023-01-05 14:50:07 +00:00
sed -i 's#' $prev_home_path '#' $new_home_path '#g' $rd_conf
2022-12-22 15:34:50 +00:00
source " $rd_conf "
2022-12-22 15:52:22 +00:00
emulators_post_move
2022-12-22 15:34:50 +00:00
fi
2022-10-07 06:48:35 +00:00
fi