Fix regex, Zenity operations and cleanup

This commit is contained in:
icenine451 2022-11-21 22:07:53 -05:00
parent 6e64317a57
commit 1827bfecda
2 changed files with 145 additions and 107 deletions

View file

@ -96,18 +96,42 @@ set_setting_value() {
case $4 in case $4 in
"emulationstation" ) "retrodeck" | "citra" | "melonds" | "yuzu" )
sed -i "s%$setting_name_to_change\" \" value=\".*\"%$setting_name_to_change\" \" value=\"$setting_value_to_change\"" $1 if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' $1
else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' $1
fi
;; ;;
* ) "retroarch" )
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
sed -i -E 's^\b'"$setting_name_to_change"'(\s?[=:]\s?).*^'"$setting_name_to_change"'\1'"$setting_value_to_change"'^' $1 sed -i 's^'"$setting_name_to_change"' = \".*\"^'"$setting_name_to_change"' = \"'"$setting_value_to_change"'\"^' $1
else else
sed -i -E '\^\['"$current_section_name"'\]|\b'"$current_section"':$^,\^\b'"$setting_name_to_change"'.*^s^\b'"$setting_name_to_change"'(\s?[=:]\s?).*^'"$setting_name_to_change"'\1'"$setting_value_to_change"'^' $1 sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"' = \".*\"^'"$setting_name_to_change"' = \"'"$setting_value_to_change"'\"^' $1
fi fi
;; ;;
"dolphin" | "duckstation" | "pcsx2" | "ppsspp" | "xemu" )
if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"' =.*^'"$setting_name_to_change"' = '"$setting_value_to_change"'^' $1
else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"' =.*^'"$setting_name_to_change"' = '"$setting_value_to_change"'^' $1
fi
;;
"rpcs3" ) # This does not currently work for settings with a $ in them
if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' $1
else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' $1
fi
;;
"emulationstation" )
sed -i "s%$setting_name_to_change\" \" value=\".*\"%$setting_name_to_change\" \" value=\"$setting_value_to_change\"" $1
;;
esac esac
} }
@ -124,7 +148,6 @@ get_setting_name() {
;; ;;
"rpcs3" ) "rpcs3" )
#echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's%\\\\%\\%g' | sed -e 's/^[ \t]*//'
echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g' echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g'
;; ;;
@ -144,25 +167,41 @@ get_setting_value() {
case $3 in case $3 in
"retrodeck" | "citra" | "melonds" | "yuzu" ) # For files with this syntax - setting_name=setting_value
if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=^$current_setting_name=).*" $1)
else
sed -n '\^\['"$section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name=).*"
fi
;;
"retroarch" ) # For files with this syntax - setting_name = "setting_value"
if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=^$current_setting_name = \").*(?=\")" $1)
else
sed -n '\^\['"$section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name = \").*(?=\")"
fi
;;
"dolphin" | "duckstation" | "pcsx2" | "ppsspp" | "xemu" ) # For files with this syntax - setting_name = setting_value
if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=^$current_setting_name = ).*" $1)
else
sed -n '\^\['"$section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name = ).*"
fi
;;
"rpcs3" ) # For files with this syntax - setting_name: setting_value
if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=$current_setting_name: ).*" $1)
else
sed -n '\^\['"$section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=$current_setting_name: ).*"
fi
;;
"emulationstation" ) "emulationstation" )
echo $(grep -o -P "(?<=^$current_setting_name\" value=\").*(?=\")" $1) echo $(grep -o -P "(?<=^$current_setting_name\" value=\").*(?=\")" $1)
;; ;;
rpcs3 )
if [[ -z $current_section_name ]]; then
sed -n -E 's^\s*\b'"$current_setting_name"'\s?:\s?(.*)^\1^p' $1
else
sed -n -E '\^\b'"$current_section"':$^,\^'"$current_setting_name"'^{ \^\b'"$current_section"':$^! { \^\b'"$current_setting_name"'^ p } }' $1 | sed -n -E 's^\s*\b.*\s?:\s?(.*)$^\1^p'
fi
;;
* )
if [[ -z $current_section_name ]]; then
sed -n -E 's^\s*\b'"$current_setting_name"'\s?=\s?(.*)^\1^p' $1
else
sed -n -E '\^\['"$current_section_name"'\]^,\^\b'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^\b'"$current_setting_name"'^ p } }' $1 | sed -n -E 's^\s*\b.*\s?=\s?(.*)^\1^p'
fi
;;
esac esac
} }

View file

@ -168,20 +168,20 @@ configurator_retroachivement_dialog() {
--add-entry="Username" \ --add-entry="Username" \
--add-password="Password") --add-password="Password")
if [ $? == 1 ] # Cancel button clicked if [ $? == 0 ]; then # OK button clicked
then 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 configurator_welcome_dialog
fi fi
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"
} }
configurator_update_dialog() { configurator_update_dialog() {
@ -194,80 +194,79 @@ configurator_power_user_changes_dialog() {
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--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?" --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 [ $? == 1 ] # Cancel button clicked if [ $? == 0 ]; then # OK button clicked
then emulator=$(zenity --list \
configurator_options_dialog --title "RetroDECK Configurator Utility - Power User Options" --cancel-label="Back" \
fi --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--text="Which emulator do you want to configure?" \
--hide-header \
--column=emulator \
"RetroArch" \
"Citra" \
"Dolphin" \
"Duckstation" \
"MelonDS" \
"PCSX2-QT" \
"PCSX2-Legacy" \
"PPSSPP" \
"RPCS3" \
"XEMU" \
"Yuzu")
emulator=$(zenity --list \ case $emulator in
--title "RetroDECK Configurator Utility - Power User Options" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--text="Which emulator do you want to configure?" \
--hide-header \
--column=emulator \
"RetroArch" \
"Citra" \
"Dolphin" \
"Duckstation" \
"MelonDS" \
"PCSX2-QT" \
"PCSX2-Legacy" \
"PPSSPP" \
"RPCS3" \
"XEMU" \
"Yuzu")
case $emulator in "RetroArch" )
retroarch
"RetroArch" )
retroarch
;;
"Citra" )
citra-qt
;;
"Dolphin" )
dolphin-emu
;;
"Duckstation" )
duckstation-qt
;;
"MelonDS" )
melonDS
;;
"PCSX2-QT" )
pcsx2-qt
;;
"PCSX2-Legacy" )
pcsx2
;;
"PPSSPP" )
PPSSPPSDL
;;
"RPCS3" )
rpcs3
;;
"XEMU" )
xemu
;;
"Yuzu" )
yuzu
;; ;;
"" ) # No selection made or Back button clicked "Citra" )
configurator_options_dialog citra-qt
;; ;;
esac "Dolphin" )
dolphin-emu
;;
"Duckstation" )
duckstation-qt
;;
"MelonDS" )
melonDS
;;
"PCSX2-QT" )
pcsx2-qt
;;
"PCSX2-Legacy" )
pcsx2
;;
"PPSSPP" )
PPSSPPSDL
;;
"RPCS3" )
rpcs3
;;
"XEMU" )
xemu
;;
"Yuzu" )
yuzu
;;
"" ) # No selection made or Back button clicked
configurator_options_dialog
;;
esac
else
configurator_options_dialog
fi
} }
configurator_retroarch_rewind_dialog() { configurator_retroarch_rewind_dialog() {
@ -279,8 +278,8 @@ configurator_retroarch_rewind_dialog() {
if [ $? == 0 ] if [ $? == 0 ]
then then
set_setting_value $raconf rewind_enable true retroarch set_setting_value $raconf "rewind_enable" "false" retroarch
configurator_process_complete_dialog "enabling Rewind" configurator_process_complete_dialog "disabling Rewind"
else else
configurator_options_dialog configurator_options_dialog
fi fi
@ -292,8 +291,8 @@ configurator_retroarch_rewind_dialog() {
if [ $? == 0 ] if [ $? == 0 ]
then then
set_setting_value $raconf rewind_enable false retroarch set_setting_value $raconf "rewind_enable" "true" retroarch
configurator_process_complete_dialog "disabling Rewind" configurator_process_complete_dialog "enabling Rewind"
else else
configurator_options_dialog configurator_options_dialog
fi fi