New retrodeck.cfg file updating

This commit is contained in:
icenine451 2023-03-08 09:51:13 -05:00
parent 1c20c8e8cf
commit 8d81ac9858
4 changed files with 37 additions and 25 deletions

View file

@ -0,0 +1,10 @@
version=
rdhome=/home/deck/retrodeck
roms_folder=/home/deck/retrodeck/roms
saves_folder=/home/deck/retrodeck/saves
states_folder=/home/deck/retrodeck/states
bios_folder=/home/deck/retrodeck/bios
media_folder=/home/deck/retrodeck/downloaded_media
themes_folder=/home/deck/retrodeck/themes
logs_folder=/home/deck/retrodeck/.logs
sdcard=/run/media/mmcblk0p1

View file

@ -166,7 +166,7 @@ desktop_mode_warning() {
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Desktop Mode Warning" \
--text="You appear to be running RetroDECK in the Steam Deck's Desktop mode!\n\nSome functions of RetroDECK may not work properly in Desktop mode, such as the Steam Decks normal controls.\n\nRetroDECK is best enjoyed in Game mode!"
--text="You appear to be running RetroDECK in the Steam Deck's Desktop mode!\n\nSome functions of RetroDECK may not work properly in Desktop mode, such as the Steam Deck's normal controls.\n\nRetroDECK is best enjoyed in Game mode!"
}
set_setting_value() {
@ -547,11 +547,24 @@ do
* )
echo "Config file malformed"
;;
esac
done < $1
}
update_rd_conf() {
# This function will import a default retrodeck.cfg file and update it with any current settings. This will allow us to expand the file over time while retaining current user settings.
# USAGE: update_rd_conf
mv -f $rd_conf $rd_conf_backup # Backup config file before update
generate_single_patch $rd_defaults $rd_conf_backup $rd_update_patch retrodeck
sed -i '/change^^version/d' $rd_update_patch # Remove version line from temporary patch file
deploy_single_patch $rd_defaults $rd_update_patch $rd_conf
rm -f $rd_update_patch # Cleanup temporary patch file
source $rd_conf # Load new config file variables
}
conf_write() {
# writes the variables in the retrodeck config file

View file

@ -6,7 +6,10 @@ source /app/libexec/functions.sh
# Static variables
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
rd_defaults="$emuconfigs/defaults/retrodeck.cfg" # A default RetroDECK config file
rd_update_patch="/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates
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)
@ -74,32 +77,17 @@ 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\"."
default_sd=$(directory_browse "SD Card Location")
fi
rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck
roms_folder="$rdhome/roms" # the default roms folder path
saves_folder="$rdhome/saves" # the default saves folder path
states_folder="$rdhome/states" # the default states folder path
bios_folder="$rdhome/bios" # the default bios folder
media_folder="$rdhome/downloaded_media" # the media folder, where all the scraped data is downloaded into
themes_folder="$rdhome/themes" # the themes folder
logs_folder="$rdhome/.logs" # the logs folder
sdcard="$default_sd" # Steam Deck SD default path
# Writing the variables for the first time
echo '#!/bin/bash' >> $rd_conf
echo "version=$version" >> $rd_conf
echo "rdhome=$rdhome" >> $rd_conf
echo "roms_folder=$roms_folder" >> $rd_conf
echo "saves_folder=$saves_folder" >> $rd_conf
echo "states_folder=$states_folder" >> $rd_conf
echo "bios_folder=$bios_folder" >> $rd_conf
echo "media_folder=$media_folder" >> $rd_conf
echo "themes_folder=$themes_folder" >> $rd_conf
echo "logs_folder=$logs_folder" >> $rd_conf
echo "sdcard=$sdcard" >> $rd_conf
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
echo "Setting config file permissions"
chmod +rw $rd_conf
echo "RetroDECK config file initialized. Contents:"
echo
cat $rd_conf
source $rd_conf # Load new variables into memory
# If the config file is existing i just read the variables (source it)
else

View file

@ -197,6 +197,7 @@ post_update() {
# The following commands are run every time.
tools_init
update_rd_conf
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \