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
rd_conf = "/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path
emuconfigs = "/app/retrodeck/emu-configs" # folder with all the default emulator configs
lockfile = "/var/config/retrodeck/.lock" # where the lockfile is located
2022-09-19 07:04:44 +00:00
default_sd = "/run/media/mmcblk0p1" # Steam Deck SD default path
2022-09-06 13:24:36 +00:00
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"
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"
# 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-09-17 15:20:39 +00:00
rdhome = " $HOME /retrodeck " # the retrodeck home, aka ~/retrodeck
roms_folder = " $rdhome /roms " # the default roms folder path
2022-09-29 21:26:02 +00:00
saves_folder = " $rdhome /saves " # the default saves folder path
states_folder = " $rdhome /states " # the default states folder path
2022-10-07 17:46:48 +00:00
bios_folder = " $rdhome /bios " # the default bios folder
2022-09-21 14:22:00 +00:00
media_folder = " $rdhome /downloaded_media " # the media folder, where all the scraped data is downloaded into
themes_folder = " $rdhome /themes " # the themes folder
2022-09-19 07:05:20 +00:00
sdcard = " $default_sd " # Steam Deck SD default path
2022-09-17 15:20:39 +00:00
2022-09-19 07:25:49 +00:00
# Writing the variables for the first time
2022-09-21 14:22:00 +00:00
echo '#!/bin/bash' >> $rd_conf
2022-09-19 07:25:49 +00:00
echo " version= $version " >> $rd_conf
echo " rdhome= $rdhome " >> $rd_conf
echo " roms_folder= $roms_folder " >> $rd_conf
2022-09-29 21:26:02 +00:00
echo " saves_folder= $saves_folder " >> $rd_conf
echo " states_folder= $states_folder " >> $rd_conf
2022-10-07 17:46:48 +00:00
echo " bios_folder= $bios_folder " >> $rd_conf
2022-09-19 07:25:49 +00:00
echo " media_folder= $media_folder " >> $rd_conf
echo " themes_folder= $themes_folder " >> $rd_conf
echo " sdcard= $sdcard " >> $rd_conf
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
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-10-07 06:48:35 +00:00
fi