mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-04-10 19:15:12 +00:00
Upgrade conf_write
so it doesn't need a list of vars to change anymore
This commit is contained in:
parent
cca6828b0f
commit
c57243bee0
77
functions.sh
77
functions.sh
|
@ -1104,67 +1104,24 @@ multi_user_selective_emu_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
conf_write() {
|
conf_write() {
|
||||||
# writes the variables in the retrodeck config file
|
# This function will update the RetroDECK config file with matching variables from memory
|
||||||
|
# USAGE: conf_write
|
||||||
|
|
||||||
echo "DEBUG: printing the config file content before writing it:"
|
while IFS= read -r current_setting_line # Read the existing retrodeck.cfg
|
||||||
cat "$rd_conf"
|
do
|
||||||
echo ""
|
if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#!/bin/bash") && (! "$current_setting_line" == "[]") ]]; then # If the line has a valid entry in it
|
||||||
|
if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header
|
||||||
echo "Writing the config file: $rd_conf"
|
current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name
|
||||||
|
else
|
||||||
# TODO: this can be optimized with a while and a list of variables to check
|
current_setting_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line
|
||||||
if [ ! -z "$version" ] #if the variable is not null then I update it
|
current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "$current_section") # Read the variables value from retrodeck.cfg
|
||||||
then
|
memory_setting_value=$(eval "echo \$${current_setting_name}") # Read the variable names' value from memory
|
||||||
sed -i "s%version=.*%version=$version%" "$rd_conf"
|
if [[ ! "$current_setting_value" == "$memory_setting_value" ]]; then # If the values are different...
|
||||||
fi
|
set_setting_value "$rd_conf" "$current_setting_name" "$memory_setting_value" "retrodeck" "$current_section" # Update the value in retrodeck.cfg
|
||||||
|
fi
|
||||||
if [ ! -z "$rdhome" ]
|
fi
|
||||||
then
|
fi
|
||||||
sed -i "s%rdhome=.*%rdhome=$rdhome%" "$rd_conf"
|
done < $rd_conf
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$roms_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%roms_folder=.*%roms_folder=$roms_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$saves_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%saves_folder=.*%saves_folder=$saves_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$states_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%states_folder=.*%states_folder=$states_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$bios_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%bios_folder=.*%bios_folder=$bios_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$media_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%media_folder=.*%media_folder=$media_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$themes_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%themes_folder=.*%themes_folder=$themes_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$logs_folder" ]
|
|
||||||
then
|
|
||||||
sed -i "s%logs_folder=.*%logs_folder=$logs_folder%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$sdcard" ]
|
|
||||||
then
|
|
||||||
sed -i "s%sdcard=.*%sdcard=$sdcard%" "$rd_conf"
|
|
||||||
fi
|
|
||||||
echo "DEBUG: New contents:"
|
|
||||||
cat "$rd_conf"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_prep() {
|
dir_prep() {
|
||||||
|
|
Loading…
Reference in a new issue