From 2c312ea74a0fadd8e2d250ea8e2b2d24966c4e9b Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 10:42:24 -0400 Subject: [PATCH 01/15] Update comments and one return code in backup_retrodeck_userdata --- functions/other_functions.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index f1878e27..0a35a8ad 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -359,7 +359,7 @@ backup_retrodeck_userdata() { # The function can also do a "core" backup of all the very important userdata files (like saves, states and gamelists) or a "custom" backup of only specified paths # The function can take both folder names as defined in retrodeck.cfg or full paths as arguments for folders to backup # It will also validate that all the provided paths exist and that there is enough free space to perform the backup before actually proceeding. - # It will also rotate backups so that there are only 3 maximum of each type (standard or custom) + # It will also rotate backups so that there are only 3 maximum of each type (complete, core or custom) # USAGE: backup_retrodeck_userdata complete # backup_retrodeck_userdata core # backup_retrodeck_userdata custom saves_folder states_folder /some/other/path @@ -377,8 +377,8 @@ backup_retrodeck_userdata() { if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then configurator_generic_dialog "RetroDECK Userdata Backup" "No valid backup option chosen. Valid options are and ." fi - log e "No valid backup option chosen. Valid options are and ." - exit 1 + log e "No valid backup option chosen. Valid options are , and ." + return 1 fi zip_file="$backups_folder/retrodeck_${backup_date}_${backup_type}.zip" @@ -547,15 +547,15 @@ backup_retrodeck_userdata() { if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then # Show progress dialog if running Zenity Configurator total_size_file=$(mktemp) # Create temp file for Zenity subshell data extraction ( - for path in "${paths_to_backup[@]}"; do - if [[ -e "$path" ]]; then - log d "Checking size of path $path" - path_size=$(du -sk "$path" 2>/dev/null | cut -f1) # Get size in KB - path_size=$((path_size * 1024)) # Convert to bytes for calculation - total_size=$((total_size + path_size)) - echo "$total_size" > $total_size_file - fi - done + for path in "${paths_to_backup[@]}"; do + if [[ -e "$path" ]]; then + log d "Checking size of path $path" + path_size=$(du -sk "$path" 2>/dev/null | cut -f1) # Get size in KB + path_size=$((path_size * 1024)) # Convert to bytes for calculation + total_size=$((total_size + path_size)) + echo "$total_size" > $total_size_file + fi + done ) | rd_zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ From 2004cc7a3e55642f8568f23183c7a95a4207c8b7 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 10:42:57 -0400 Subject: [PATCH 02/15] Fix Zenity dialog arguments in post_update backup dialog --- functions/post_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/post_update.sh b/functions/post_update.sh index edd583c9..010fee13 100644 --- a/functions/post_update.sh +++ b/functions/post_update.sh @@ -13,7 +13,7 @@ post_update() { # Optional userdata backup prior to update - choice=$(rd_zenity --title "RetroDECK Update - Backup Userdata" --info --no-wrap --ok-label="No Backup" --extra-button"Backup Core Userdata" --extra-button="Backup Some Userdata" --extra-button="Backup All Userdata" \ + choice=$(rd_zenity --title "RetroDECK Update - Backup Userdata" --info --no-wrap --ok-label="No Backup" --extra-button="Backup Core Userdata" --extra-button="Backup Some Userdata" --extra-button="Backup All Userdata" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="Would you like to backup some or all of the RetroDECK userdata prior to update?\n\nIf you choose \"Backup Core Userdata\" only irreplaceable files (like saves, states and gamelists) will be backed up. If you choose \"Backup Some Userdata\" you will be given a choice of which folders to backup.\n\nIf you choose \"Backup All Userdata\" then ALL data (including ROMs and downloaded media) will be backed up.\nPLEASE NOTE: A full backup may take up a large amount of space, especially if you have a lot of scraped media.") local rc=$? From fafba97ad4b3ce6fdba726a4a9d1c35d34c3dbe7 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 11:07:45 -0400 Subject: [PATCH 03/15] Add core userdata backup option to post_update and give user option to exit update process if backup fails --- functions/post_update.sh | 94 ++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/functions/post_update.sh b/functions/post_update.sh index 010fee13..392443eb 100644 --- a/functions/post_update.sh +++ b/functions/post_update.sh @@ -17,47 +17,65 @@ post_update() { --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="Would you like to backup some or all of the RetroDECK userdata prior to update?\n\nIf you choose \"Backup Core Userdata\" only irreplaceable files (like saves, states and gamelists) will be backed up. If you choose \"Backup Some Userdata\" you will be given a choice of which folders to backup.\n\nIf you choose \"Backup All Userdata\" then ALL data (including ROMs and downloaded media) will be backed up.\nPLEASE NOTE: A full backup may take up a large amount of space, especially if you have a lot of scraped media.") local rc=$? - if [[ $rc == "0" ]] && [[ -z "$choice" ]]; then # User selected No Backup button - log i "User chose to not backup prior to update." - else - case $choice in - "Backup Core Userdata" ) - log i "User chose to backup core userdata prior to update." - backup_retrodeck_userdata "core" - ;; - "Backup Some Userdata" ) - log i "User chose to backup some userdata prior to update." - while read -r config_line; do - local current_setting_name=$(get_setting_name "$config_line" "retrodeck") - if [[ ! $current_setting_name =~ (rdhome|sdcard|backups_folder) ]]; then # Ignore these locations - log d "Adding $current_setting_name to compressible paths." - local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "paths") - compressible_paths=("${compressible_paths[@]}" "false" "$current_setting_name" "$current_setting_value") - fi - done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') + if [[ $rc == "0" ]] && [[ -z "$choice" ]]; then # User selected No Backup button + log i "User chose to not backup prior to update." + else + case $choice in + "Backup Core Userdata" ) + log i "User chose to backup core userdata prior to update." + if ! backup_retrodeck_userdata "core"; then + log d "Userdata backup failed, giving option to proceed" + if [[ $(configurator_generic_question_dialog "RetroDECK Update" "Unfortunately the userdata backup process was not successful.\nWould you like to proceed with the upgrade anyway?\n\nRetroDECK will exit if you choose \"No\"") == "false" ]]; then + log d "User chose to stop post_update process after backup failure" + exit 1 + fi + fi + ;; + "Backup Some Userdata" ) + log i "User chose to backup some userdata prior to update." + while read -r config_line; do + local current_setting_name=$(get_setting_name "$config_line" "retrodeck") + if [[ ! $current_setting_name =~ (rdhome|sdcard|backups_folder) ]]; then # Ignore these locations + log d "Adding $current_setting_name to compressible paths." + local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "paths") + compressible_paths=("${compressible_paths[@]}" "false" "$current_setting_name" "$current_setting_value") + fi + done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') - choice=$(rd_zenity \ - --list --width=1200 --height=720 \ - --checklist \ - --separator="^" \ - --print-column=3 \ - --text="Please select folders to compress..." \ - --column "Backup?" \ - --column "Folder Name" \ - --column "Path" \ - "${compressible_paths[@]}") + choice=$(rd_zenity \ + --list --width=1200 --height=720 \ + --checklist \ + --separator="^" \ + --print-column=3 \ + --text="Please select folders to compress..." \ + --column "Backup?" \ + --column "Folder Name" \ + --column "Path" \ + "${compressible_paths[@]}") - choices=() # Expand choice string into passable array - IFS='^' read -ra choices <<< "$choice" + choices=() # Expand choice string into passable array + IFS='^' read -ra choices <<< "$choice" - backup_retrodeck_userdata "custom" "${choices[@]}" # Expand array of choices into individual arguments - ;; - "Backup All Userdata" ) - log i "User chose to backup all userdata prior to update." - backup_retrodeck_userdata "complete" - ;; - esac - fi + if ! backup_retrodeck_userdata "custom" "${choices[@]}"; then # Expand array of choices into individual arguments + log d "Userdata backup failed, giving option to proceed" + if [[ $(configurator_generic_question_dialog "RetroDECK Update" "Unfortunately the userdata backup process was not successful.\nWould you like to proceed with the upgrade anyway?\n\nRetroDECK will exit if you choose \"No\"") == "false" ]]; then + log d "User chose to stop post_update process after backup failure" + exit 1 + fi + fi + ;; + "Backup All Userdata" ) + log i "User chose to backup all userdata prior to update." + if ! backup_retrodeck_userdata "complete"; then + log d "Userdata backup failed, giving option to proceed" + if [[ $(configurator_generic_question_dialog "RetroDECK Update" "Unfortunately the userdata backup process was not successful.\nWould you like to proceed with the upgrade anyway?\n\nRetroDECK will exit if you choose \"No\"") == "false" ]]; then + log d "User chose to stop post_update process after backup failure" + exit 1 + fi + fi + ;; + esac + fi # Start of post_update actions From 6c8f006da7df2f93e39de08204240e79abe924e5 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 11:12:36 -0400 Subject: [PATCH 04/15] Update CLI help information and add steam-sync CLI option --- retrodeck.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/retrodeck.sh b/retrodeck.sh index 75a60005..ede8a51f 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -14,6 +14,8 @@ Arguments: --configurator \t Starts the RetroDECK Configurator --compress-one \t Compresses target file to a compatible format --compress-all \t Compresses all supported games into a compatible format.\n\t\t\t\t\t\t Available formats are \"chd\", \"zip\", \"rvz\" and \"all\" + --steam-sync \t Run the Steam ROM Manager sync process to update all ES-DE favorites in Steam + --repair-paths \t Reconfigure broken folder locations in RetroDECK without a full reset --reset \t Reset RetroDECK or one or more component/emulator configurations to default values. WARNING: no confirmation prompt --factory-reset \t Factory Reset, triggers the initial setup WARNING: no confirmation prompt --test-upgrade \t Test upgrading RetroDECK to a specific version, developer use only @@ -109,6 +111,10 @@ while [[ $# -gt 0 ]]; do cli_compress_all_games "$2" shift 2 ;; + --steam-sync) + steam_sync + exit 0 + ;; --repair-paths) repair_paths exit 0 From 020ad0e51ff5845de9f056fc44e287e73c5e9439 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 11:47:06 -0400 Subject: [PATCH 05/15] Update steam_sync to only run SRM add process if new games were favorited in ES-DE --- functions/global.sh | 1 + functions/steam_sync.sh | 87 +++++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/functions/global.sh b/functions/global.sh index 8948b352..b2420606 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -262,6 +262,7 @@ fi steamsync_folder="$rdhome/.sync" # Folder containing favorites manifest for SRM retrodeck_favorites_file="$steamsync_folder/retrodeck_favorites.json" # The current SRM manifest of all games that have been favorited in ES-DE srm_log="$logs_folder/srm_log.log" # Log file for capturing the output of the most recent SRM run, for debugging purposes +retrodeck_added_favorites="$steamsync_folder/retrodeck_added_favorites.json" # Temporary manifest of any games that were newly added to the ES-DE favorites and should be added to Steam retrodeck_removed_favorites="$steamsync_folder/retrodeck_removed_favorites.json" # Temporary manifest of any games that were unfavorited in ES-DE and should be removed from Steam export GLOBAL_SOURCED=true diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index 5a34e290..522fd94f 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -61,12 +61,26 @@ steam_sync() { '[$source[0][] | select(. as $item | ($target[0] | map(. == $item) | any | not))]') fi + if [[ -f "$retrodeck_favorites_file" && -f "${retrodeck_favorites_file}.new" ]]; then + # Look for new favorites added between steam_sync runs, if any + added_items=$(jq -n \ + --slurpfile source "${retrodeck_favorites_file}.new" \ + --slurpfile target "$retrodeck_favorites_file" \ + '[$source[0][] | select(. as $item | ($target[0] | map(. == $item) | any | not))]') + fi + # Check if there are any missing objects if [[ "$(echo "$removed_items" | jq 'length')" -gt 0 ]]; then log d "Some favorites were removed between sync, writing to $retrodeck_removed_favorites" echo "$removed_items" > "$retrodeck_removed_favorites" fi + # Check if any new favorites were added + if [[ "$(echo "$added_items" | jq 'length')" -gt 0 ]]; then + log d "Some new favorites were added between sync, writing to $retrodeck_added_favorites" + echo "$added_items" > "$retrodeck_added_favorites" + fi + # Decide if sync needs to happen if [[ -f "$retrodeck_favorites_file" ]]; then # If an existing favorites manifest exists if [[ ! "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # If all favorites were removed from all gamelists, meaning new manifest is empty @@ -74,9 +88,7 @@ steam_sync() { if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then ( # Remove old entries - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager remove >> "$srm_log" 2>&1 + steam_sync_remove ) | rd_zenity --progress \ --title="Syncing with Steam" \ @@ -85,9 +97,7 @@ steam_sync() { --pulsate --width=500 --height=150 --auto-close --no-cancel else # Remove old entries - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager remove >> "$srm_log" 2>&1 + steam_sync_remove fi # Old manifest cleanup rm "$retrodeck_favorites_file" @@ -104,9 +114,7 @@ steam_sync() { mv "$retrodeck_removed_favorites" "$retrodeck_favorites_file" if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then ( - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager remove >> "$srm_log" 2>&1 + steam_sync_remove ) | rd_zenity --progress \ --title="Syncing with Steam" \ @@ -114,32 +122,29 @@ steam_sync() { --text="\t\t\t\tRemoving unfavorited games from Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ --pulsate --width=500 --height=150 --auto-close --no-cancel else - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager remove >> "$srm_log" 2>&1 + steam_sync_remove + fi + fi + if [[ -f "$retrodeck_added_favorites" ]]; then # If some new favorites were added between syncs + log d "Some new favorites added between syncs, adding new favorited games" + # Load added favorites as manifest and run SRM add + mv "$retrodeck_added_favorites" "$retrodeck_favorites_file" + if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then + ( + steam_sync_add + ) | + rd_zenity --progress \ + --title="Syncing with Steam" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --text="\t\t\t\tAdding new favorited games to Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ + --pulsate --width=500 --height=150 --auto-close --no-cancel + else + steam_sync_add fi fi - # Load new favorites manifest as games to add during sync + # Make new favorites manifest the current one mv "${retrodeck_favorites_file}.new" "$retrodeck_favorites_file" - - if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then - ( - # Add new favorites manifest - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager add >> "$srm_log" 2>&1 - ) | - rd_zenity --progress \ - --title="Syncing with Steam" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --text="\t\t\t\tSyncing favorite games with Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ - --pulsate --width=500 --height=150 --auto-close --no-cancel - else - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager add >> "$srm_log" 2>&1 - fi fi fi elif [[ "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # No existing favorites manifest was found, so check if new manifest has entries @@ -148,9 +153,7 @@ steam_sync() { if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then ( # Add new favorites manifest - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager add >> "$srm_log" 2>&1 + steam_sync_add ) | rd_zenity --progress \ --title="Syncing with Steam" \ @@ -159,9 +162,19 @@ steam_sync() { --pulsate --width=500 --height=150 --auto-close --no-cancel else # Add new favorites manifest - steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 - steam-rom-manager add >> "$srm_log" 2>&1 + steam_sync_add fi fi } + +steam_sync_add() { + steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 + steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 + steam-rom-manager add >> "$srm_log" 2>&1 +} + +steam_sync_remove() { + steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 + steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 + steam-rom-manager remove >> "$srm_log" 2>&1 +} From 34a24c230511923dcbf14f4fc4d8644366d525ec Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 13:55:20 -0400 Subject: [PATCH 06/15] Make 0.9.2b post_update Steam Sync nuke optional --- functions/post_update.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/functions/post_update.sh b/functions/post_update.sh index 392443eb..152358da 100644 --- a/functions/post_update.sh +++ b/functions/post_update.sh @@ -746,22 +746,24 @@ post_update() { if [[ $(check_version_is_older_than "$version_being_updated" "0.9.2b") == "true" ]]; then # In version 0.9.2b, the following changes were made that required config file updates/reset or other changes to the filesystem: - # Steam Sync completely rebuilt into new manifest system. Favorites will need to be nuked and, if steam_sync is enabled will be rebuilt. + # Steam Sync completely rebuilt into new manifest system. Favorites may need to be nuked and, if steam_sync is enabled will be rebuilt. This is an optional step. - if [[ -d "$steamsync_folder" ]]; then # If Steam Sync has ever been run - steam-rom-manager nuke - steam_sync - if [[ "$(configurator_generic_question_dialog "RetroDECK 0.9.2b Steam Sync Reset" "In RetroDECK 0.9.2b we upgraded our Steam Sync feature and the shortcuts in Steam need to be rebuilt.\n\nAll of your ES-DE favorites are still unchanged.\nAny games you have favorited now will be recreated.\n\nIf you have added RetroDECK to Steam through our Configurator it will also be removed through this process.\nWould you like to add the RetroDECK shortcut again?")" == "true" ]]; then - ( - # Add RetroDECK launcher to Steam - steam-rom-manager enable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 - steam-rom-manager add >> "$srm_log" 2>&1 - ) | - rd_zenity --progress \ - --title="RetroDECK Configurator: Add RetroDECK to Steam" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --text="Adding RetroDECK launcher to Steam, please wait..." \ - --pulsate --width=500 --height=150 --auto-close --no-cancel + if [[ -d "$steamsync_folder" && ! -z $(ls -1 "$steamsync_folder") ]]; then # If Steam Sync folder exists and is not empty + if [[ "$(configurator_generic_question_dialog "RetroDECK 0.9.2b Steam Sync Reset" "In RetroDECK 0.9.2b we upgraded our Steam Sync feature and the shortcuts in Steam may need to be rebuilt.\n\nAll of your ES-DE favorites are still unchanged.\nAny games you have favorited now will be recreated, but last-played information and custom artwork changes may be lost.\n\nIf you have added RetroDECK to Steam through our Configurator it will also be removed through this process.\nWould you like to refresh the RetroDECK Steam Sync system?")" == "true" ]]; then + steam-rom-manager nuke + steam_sync + if [[ "$(configurator_generic_question_dialog "RetroDECK 0.9.2b Steam Sync Reset" "The Steam Sync reset is complete.\nIf you had previously added a RetroDECK shortcut to Steam through our tools, it would have also been removed.\n\nWould you like to add the RetroDECK shortcut now?")" == "true" ]]; then + ( + # Add RetroDECK launcher to Steam + steam-rom-manager enable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 + steam-rom-manager add >> "$srm_log" 2>&1 + ) | + rd_zenity --progress \ + --title="RetroDECK Configurator: Add RetroDECK to Steam" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --text="Adding RetroDECK launcher to Steam, please wait..." \ + --pulsate --width=500 --height=150 --auto-close --no-cancel + fi fi fi From 3ae4eac4f9e45cf1e023a5e6e40b6e8eca4524f8 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 13:59:23 -0400 Subject: [PATCH 07/15] Update metainfo for 0.9.2b --- net.retrodeck.retrodeck.metainfo.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net.retrodeck.retrodeck.metainfo.xml b/net.retrodeck.retrodeck.metainfo.xml index fab4e543..d14cfb4c 100644 --- a/net.retrodeck.retrodeck.metainfo.xml +++ b/net.retrodeck.retrodeck.metainfo.xml @@ -73,6 +73,9 @@ GPL-3.0 CC0-1.0 + + https://github.com/RetroDECK/RetroDECK/releases/tag/0.9.2b + https://github.com/RetroDECK/RetroDECK/releases/tag/0.9.1b From aabbc414988cf713e945c55a2a4ecec030b906d8 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 16:51:17 -0400 Subject: [PATCH 08/15] Fix lots of issues with paths containing spaces in prepare_component --- functions/prepare_component.sh | 58 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/functions/prepare_component.sh b/functions/prepare_component.sh index 08ad8357..ad2b2efd 100644 --- a/functions/prepare_component.sh +++ b/functions/prepare_component.sh @@ -134,8 +134,8 @@ prepare_component() { cp -fvr "$config/steam-rom-manager/manifests" "$srm_userdata" log i "Updating steamDirectory and romDirectory lines in $srm_userdata/userSettings.json" - jq '.environmentVariables.steamDirectory = "'$HOME'/.steam/steam"' "$srm_userdata/userSettings.json" > "$srm_userdata/tmp.json" && mv -f "$srm_userdata/tmp.json" "$srm_userdata/userSettings.json" - jq '.environmentVariables.romsDirectory = "'$rdhome'/.sync"' "$srm_userdata/userSettings.json" > "$srm_userdata/tmp.json" && mv -f "$srm_userdata/tmp.json" "$srm_userdata/userSettings.json" + jq '.environmentVariables.steamDirectory = "'"$HOME"'/.steam/steam"' "$srm_userdata/userSettings.json" > "$srm_userdata/tmp.json" && mv -f "$srm_userdata/tmp.json" "$srm_userdata/userSettings.json" + jq '.environmentVariables.romsDirectory = "'"$rdhome"'/.sync"' "$srm_userdata/userSettings.json" > "$srm_userdata/tmp.json" && mv -f "$srm_userdata/tmp.json" "$srm_userdata/userSettings.json" get_steam_user fi @@ -200,14 +200,14 @@ prepare_component() { log i "--------------------------------" log i "Prepearing PPSSPP_LIBRETRO" log i "--------------------------------" - if [ -d $bios_folder/PPSSPP/flash0/font ] + if [ -d "$bios_folder/PPSSPP/flash0/font" ] then - mv -fv $bios_folder/PPSSPP/flash0/font $bios_folder/PPSSPP/flash0/font.bak + mv -fv "$bios_folder/PPSSPP/flash0/font" "$bios_folder/PPSSPP/flash0/font.bak" fi cp -rf "/app/retrodeck/extras/PPSSPP" "$bios_folder/PPSSPP" - if [ -d $bios_folder/PPSSPP/flash0/font.bak ] + if [ -d "$bios_folder/PPSSPP/flash0/font.bak" ] then - mv -f $bios_folder/PPSSPP/flash0/font.bak $bios_folder/PPSSPP/flash0/font + mv -f "$bios_folder/PPSSPP/flash0/font.bak" "$bios_folder/PPSSPP/flash0/font" fi # MSX / SVI / ColecoVision / SG-1000 @@ -350,7 +350,9 @@ prepare_component() { cp -fr "$config/cemu/"* /var/config/Cemu/ set_setting_value "$cemuconf" "mlc_path" "$bios_folder/cemu" "cemu" set_setting_value "$cemuconf" "Entry" "$roms_folder/wiiu" "cemu" "GamePaths" - rm -rf "$XDG_DATA_HOME/Cemu/keys.txt" && ln -s "$bios_folder/cemu/keys.txt" "$XDG_DATA_HOME/Cemu/keys.txt" && log d "Linked $bios_folder/cemu/keys.txt to $XDG_DATA_HOME/Cemu/keys.txt" + if [[ -e "$bios_folder/cemu/keys.txt" ]]; then + rm -rf "$XDG_DATA_HOME/Cemu/keys.txt" && ln -s "$bios_folder/cemu/keys.txt" "$XDG_DATA_HOME/Cemu/keys.txt" && log d "Linked $bios_folder/cemu/keys.txt to $XDG_DATA_HOME/Cemu/keys.txt" + fi fi # Shared actions dir_prep "$saves_folder/wiiu/cemu" "$bios_folder/cemu/usr/save" @@ -591,7 +593,7 @@ prepare_component() { dir_prep "$texture_packs_folder/PPSSPP" "/var/config/ppsspp/PSP/TEXTURES" create_dir -d "$cheats_folder/PPSSPP" dir_prep "$cheats_folder/PPSSPP" "/var/config/ppsspp/PSP/Cheats" - if [[ -d "$cheats_folder/PPSSPP" && "$(ls -A $cheats_folder/PPSSPP)" ]]; then + if [[ -d "$cheats_folder/PPSSPP" && "$(ls -A "$cheats_folder"/PPSSPP)" ]]; then backup_file="$backups_folder/cheats/PPSSPP-$(date +%y%m%d).tar.gz" create_dir "$(dirname "$backup_file")" tar -czf "$backup_file" -C "$cheats_folder" PPSSPP @@ -640,7 +642,9 @@ prepare_component() { dir_prep "$saves_folder/wii/primehack" "/var/data/primehack/Wii" dir_prep "$mods_folder/Primehack" "/var/data/primehack/Load/GraphicMods" dir_prep "$texture_packs_folder/Primehack" "/var/data/primehack/Load/Textures" - cp -fvr "$config/primehack/data/"* "$multi_user_data_folder/$SteamAppUser/data/primehack/" # this must be done after the dirs are prepared as it copying some "mods" + if [[ $multi_user_mode == "true" ]]; then # Multi-user actions + cp -fvr "$config/primehack/data/"* "$multi_user_data_folder/$SteamAppUser/data/primehack/" # this must be done after the dirs are prepared as it copying some "mods" + fi # Reset default preset settings set_setting_value "$rd_conf" "primehack" "$(get_setting_value "$rd_defaults" "primehack" "retrodeck" "ask_to_exit")" "retrodeck" "ask_to_exit" @@ -708,17 +712,17 @@ prepare_component() { rm -rf "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" #create_dir "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/system" cp -fv $config/ryujinx/* "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" - sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/Config.json" + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/Config.json" dir_prep "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" "/var/config/Ryujinx" else # removing config directory to wipe legacy files log d "Removing \"/var/config/Ryujinx\"" - rm -rf /var/config/Ryujinx - create_dir /var/config/Ryujinx/system - cp -fv $config/ryujinx/Config.json $ryujinxconf - cp -fvr $config/ryujinx/profiles /var/config/Ryujinx/ + rm -rf "/var/config/Ryujinx" + create_dir "/var/config/Ryujinx/system" + cp -fv "$config/ryujinx/Config.json" "$ryujinxconf" + cp -fvr "$config/ryujinx/profiles" "/var/config/Ryujinx/" log d "Replacing placeholders in \"$ryujinxconf\"" - sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$ryujinxconf" + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$ryujinxconf" create_dir "$logs_folder/ryujinx" create_dir "$mods_folder/ryujinx" create_dir "$screenshots_folder/ryujinx" @@ -796,10 +800,10 @@ prepare_component() { log i "Prepearing XEMU" log i "------------------------" if [[ $multi_user_mode == "true" ]]; then # Multi-user actions - rm -rf /var/config/xemu - rm -rf /var/data/xemu + rm -rf "/var/config/xemu" + rm -rf "/var/data/xemu" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/xemu/" - cp -fv $config/xemu/xemu.toml "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" + cp -fv "$config/xemu/xemu.toml" "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "screenshot_dir" "'$screenshots_folder'" "xemu" "General" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "bootrom_path" "'$bios_folder/mcpx_1.0.bin'" "xemu" "sys.files" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "flashrom_path" "'$bios_folder/Complex.bin'" "xemu" "sys.files" @@ -808,19 +812,19 @@ prepare_component() { dir_prep "$multi_user_data_folder/$SteamAppUser/config/xemu" "/var/config/xemu" # Creating config folder in /var/config for consistentcy and linking back to original location where component will look dir_prep "$multi_user_data_folder/$SteamAppUser/config/xemu" "/var/data/xemu/xemu" else # Single-user actions - rm -rf /var/config/xemu - rm -rf /var/data/xemu + rm -rf "/var/config/xemu" + rm -rf "/var/data/xemu" dir_prep "/var/config/xemu" "/var/data/xemu/xemu" # Creating config folder in /var/config for consistentcy and linking back to original location where component will look - cp -fv $config/xemu/xemu.toml "$xemuconf" + cp -fv "$config/xemu/xemu.toml" "$xemuconf" set_setting_value "$xemuconf" "screenshot_dir" "'$screenshots_folder'" "xemu" "General" set_setting_value "$xemuconf" "bootrom_path" "'$bios_folder/mcpx_1.0.bin'" "xemu" "sys.files" set_setting_value "$xemuconf" "flashrom_path" "'$bios_folder/Complex.bin'" "xemu" "sys.files" set_setting_value "$xemuconf" "eeprom_path" "'$saves_folder/xbox/xemu/xbox-eeprom.bin'" "xemu" "sys.files" set_setting_value "$xemuconf" "hdd_path" "'$bios_folder/xbox_hdd.qcow2'" "xemu" "sys.files" fi # Shared actions - create_dir $saves_folder/xbox/xemu/ + create_dir "$saves_folder/xbox/xemu/" # Preparing HD dummy Image if the image is not found - if [ ! -f $bios_folder/xbox_hdd.qcow2 ] + if [ ! -f "$bios_folder/xbox_hdd.qcow2" ] then cp -f "/app/retrodeck/extras/XEMU/xbox_hdd.qcow2" "$bios_folder/xbox_hdd.qcow2" fi @@ -918,7 +922,7 @@ prepare_component() { cp -fvr "$config/mame/default.cfg" "$mamedefconf" cp -fvr "/app/share/mame/bgfx/"* "$shaders_folder/mame/bgfx" - sed -i 's#RETRODECKROMSDIR#'$roms_folder'#g' "$mameconf" # one-off as roms folders are a lot + sed -i 's#RETRODECKROMSDIR#'"$roms_folder"'#g' "$mameconf" # one-off as roms folders are a lot set_setting_value "$mameconf" "nvram_directory" "$saves_folder/mame-sa/nvram" "mame" set_setting_value "$mameconf" "state_directory" "$states_folder/mame-sa" "mame" set_setting_value "$mameconf" "snapshot_directory" "$screenshots_folder/mame-sa" "mame" @@ -948,9 +952,9 @@ prepare_component() { cp -fvr "$config/gzdoom/gzdoom.ini" "/var/config/gzdoom" - sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON - sed -i 's#RETRODECKROMSDIR#'$roms_folder'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON - sed -i 's#RETRODECKSAVESDIR#'$saves_folder'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKROMSDIR#'"$roms_folder"'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKSAVESDIR#'"$saves_folder"'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON fi if [[ "$component" =~ ^(portmaster|all)$ ]]; then From 6d7e8beb9394d14d9a8c2140b17bf6b0d833a5a7 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 16:51:33 -0400 Subject: [PATCH 09/15] Remove helper file definition for file that no longer exists --- config/retrodeck/reference_lists/features.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/retrodeck/reference_lists/features.json b/config/retrodeck/reference_lists/features.json index 90efff2c..375b0c34 100644 --- a/config/retrodeck/reference_lists/features.json +++ b/config/retrodeck/reference_lists/features.json @@ -213,10 +213,6 @@ "filename": "how-to-install-psvita-games.txt", "location": "$roms_folder/psvita" }, - "ryujinx_firmware": { - "filename": "Install-firmware-through-Ryujinx.txt", - "location": "$bios_folder/switch/firmware" - }, "custom_systems": { "filename": "es_systems.xml", "location": "$rdhome/ES-DE/custom_systems" From 9768a82d095d5bcf4b4f3fedb3f725828f63bd6d Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 17:26:47 -0400 Subject: [PATCH 10/15] Reduce code duplication in steam_sync --- functions/steam_sync.sh | 288 +++++++++++++++++++--------------------- 1 file changed, 133 insertions(+), 155 deletions(-) diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index 522fd94f..75a89af6 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -2,179 +2,157 @@ steam_sync() { - # This function looks for favorited games in all ES-DE gamelists and builds a manifest of any found. - # It then compares the new manifest to the existing one (if it exists) and runs an SRM sync if there are differences - # If all favorites were removed from ES-DE, it will remove all existing entries from Steam and then remove the favorites manifest entirely - # If there is no existing manifest, this is a first time sync and games are synced automatically - # USAGE: steam_sync + # This function looks for favorited games in all ES-DE gamelists and builds a manifest of any found. + # It then compares the new manifest to the existing one (if it exists) and runs an SRM sync if there are differences + # If all favorites were removed from ES-DE, it will remove all existing entries from Steam and then remove the favorites manifest entirely + # If there is no existing manifest, this is a first time sync and games are synced automatically + # USAGE: steam_sync - log "i" "Starting Steam Sync" - create_dir $steamsync_folder + log "i" "Starting Steam Sync" + create_dir $steamsync_folder - if [ ! -f "$srm_path" ]; then - log "e" "Steam ROM Manager configuration not initialized! Initializing now." - prepare_component "reset" "steam-rom-manager" + if [ ! -f "$srm_path" ]; then + log "e" "Steam ROM Manager configuration not initialized! Initializing now." + prepare_component "reset" "steam-rom-manager" + fi + + # Prepare fresh log file + echo > "$srm_log" + + # Prepare new favorites manifest + echo "[]" > "${retrodeck_favorites_file}.new" # Initialize favorites JSON file + + # Static definitions for all JSON objects + target="flatpak" + launch_command="run net.retrodeck.retrodeck" + startIn="" + + for system_path in "$rdhome/ES-DE/gamelists/"*/; do + # Skip the CLEANUP folder + if [[ "$system_path" == *"/CLEANUP/"* ]]; then + continue fi - - # Prepare fresh log file - echo > "$srm_log" - - # Prepare new favorites manifest - echo "[]" > "${retrodeck_favorites_file}.new" # Initialize favorites JSON file - - # Static definitions for all JSON objects - target="flatpak" - launch_command="run net.retrodeck.retrodeck" - startIn="" - - for system_path in "$rdhome/ES-DE/gamelists/"*/; do - # Skip the CLEANUP folder - if [[ "$system_path" == *"/CLEANUP/"* ]]; then - continue + # Skip folders with no gamelists + if [[ ! -f "${system_path}gamelist.xml" ]]; then + continue + fi + system=$(basename "$system_path") # Extract the folder name as the system name + gamelist="${system_path}gamelist.xml" + system_favorites=$(xml sel -t -m "//game[favorite='true']" -v "path" -n "$gamelist") + while read -r game; do + if [[ -n "$game" ]]; then # Avoid empty lines created by xmlstarlet + local game="${game#./}" # Remove leading ./ + if [[ -f "$roms_folder/$system/$game" ]]; then # Validate file exists and isn't a stale ES-DE entry for a removed file + # Construct launch options with the rom path in quotes, to handle spaces + local launchOptions="$launch_command -s $system \"$roms_folder/$system/$game\"" + jq --arg title "${game%.*}" --arg target "$target" --arg launchOptions "$launchOptions" \ + '. += [{"title": $title, "target": $target, "launchOptions": $launchOptions}]' "${retrodeck_favorites_file}.new" > "${retrodeck_favorites_file}.tmp" \ + && mv "${retrodeck_favorites_file}.tmp" "${retrodeck_favorites_file}.new" fi - # Skip folders with no gamelists - if [[ ! -f "${system_path}gamelist.xml" ]]; then - continue + fi + done <<< "$system_favorites" + done + + if [[ -f "$retrodeck_favorites_file" && -f "${retrodeck_favorites_file}.new" ]]; then + # Look for favorites removed between steam_sync runs, if any + removed_items=$(jq -n \ + --slurpfile source "$retrodeck_favorites_file" \ + --slurpfile target "${retrodeck_favorites_file}.new" \ + '[$source[0][] | select(. as $item | ($target[0] | map(. == $item) | any | not))]') + fi + + if [[ -f "$retrodeck_favorites_file" && -f "${retrodeck_favorites_file}.new" ]]; then + # Look for new favorites added between steam_sync runs, if any + added_items=$(jq -n \ + --slurpfile source "${retrodeck_favorites_file}.new" \ + --slurpfile target "$retrodeck_favorites_file" \ + '[$source[0][] | select(. as $item | ($target[0] | map(. == $item) | any | not))]') + fi + + # Check if there are any missing objects + if [[ "$(echo "$removed_items" | jq 'length')" -gt 0 ]]; then + log d "Some favorites were removed between sync, writing to $retrodeck_removed_favorites" + echo "$removed_items" > "$retrodeck_removed_favorites" + fi + + # Check if any new favorites were added + if [[ "$(echo "$added_items" | jq 'length')" -gt 0 ]]; then + log d "Some new favorites were added between sync, writing to $retrodeck_added_favorites" + echo "$added_items" > "$retrodeck_added_favorites" + fi + + # Decide if sync needs to happen + if [[ -f "$retrodeck_favorites_file" ]]; then # If an existing favorites manifest exists + if [[ ! "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # If all favorites were removed from all gamelists, meaning new manifest is empty + log i "No favorites were found in current ES-DE gamelists, removing old entries" + steam_sync_remove + # Old manifest cleanup + rm "$retrodeck_favorites_file" + rm "${retrodeck_favorites_file}.new" + else # The new favorites manifest is not empty + if cmp -s "$retrodeck_favorites_file" "${retrodeck_favorites_file}.new"; then # See if the favorites manifests are the same, meaning there were no changes + log i "ES-DE favorites have not changed, no need to sync again" + rm "${retrodeck_favorites_file}.new" + else + log d "New and old manifests are different, running sync" + if [[ -f "$retrodeck_removed_favorites" ]]; then # If some favorites were removed between syncs + log d "Some favorites removed between syncs, removing unfavorited games" + # Load removed favorites as manifest and run SRM remove + mv "$retrodeck_removed_favorites" "$retrodeck_favorites_file" + steam_sync_remove fi - system=$(basename "$system_path") # Extract the folder name as the system name - gamelist="${system_path}gamelist.xml" - system_favorites=$(xml sel -t -m "//game[favorite='true']" -v "path" -n "$gamelist") - while read -r game; do - if [[ -n "$game" ]]; then # Avoid empty lines created by xmlstarlet - local game="${game#./}" # Remove leading ./ - if [[ -f "$roms_folder/$system/$game" ]]; then # Validate file exists and isn't a stale ES-DE entry for a removed file - # Construct launch options with the rom path in quotes, to handle spaces - local launchOptions="$launch_command -s $system \"$roms_folder/$system/$game\"" - jq --arg title "${game%.*}" --arg target "$target" --arg launchOptions "$launchOptions" \ - '. += [{"title": $title, "target": $target, "launchOptions": $launchOptions}]' "${retrodeck_favorites_file}.new" > "${retrodeck_favorites_file}.tmp" \ - && mv "${retrodeck_favorites_file}.tmp" "${retrodeck_favorites_file}.new" - fi - fi - done <<< "$system_favorites" - done - - if [[ -f "$retrodeck_favorites_file" && -f "${retrodeck_favorites_file}.new" ]]; then - # Look for favorites removed between steam_sync runs, if any - removed_items=$(jq -n \ - --slurpfile source "$retrodeck_favorites_file" \ - --slurpfile target "${retrodeck_favorites_file}.new" \ - '[$source[0][] | select(. as $item | ($target[0] | map(. == $item) | any | not))]') - fi - - if [[ -f "$retrodeck_favorites_file" && -f "${retrodeck_favorites_file}.new" ]]; then - # Look for new favorites added between steam_sync runs, if any - added_items=$(jq -n \ - --slurpfile source "${retrodeck_favorites_file}.new" \ - --slurpfile target "$retrodeck_favorites_file" \ - '[$source[0][] | select(. as $item | ($target[0] | map(. == $item) | any | not))]') - fi - - # Check if there are any missing objects - if [[ "$(echo "$removed_items" | jq 'length')" -gt 0 ]]; then - log d "Some favorites were removed between sync, writing to $retrodeck_removed_favorites" - echo "$removed_items" > "$retrodeck_removed_favorites" - fi - - # Check if any new favorites were added - if [[ "$(echo "$added_items" | jq 'length')" -gt 0 ]]; then - log d "Some new favorites were added between sync, writing to $retrodeck_added_favorites" - echo "$added_items" > "$retrodeck_added_favorites" - fi - - # Decide if sync needs to happen - if [[ -f "$retrodeck_favorites_file" ]]; then # If an existing favorites manifest exists - if [[ ! "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # If all favorites were removed from all gamelists, meaning new manifest is empty - log i "No favorites were found in current ES-DE gamelists, removing old entries" - if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then - ( - # Remove old entries - steam_sync_remove - ) | - rd_zenity --progress \ - --title="Syncing with Steam" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --text="\t\t\t\tRemoving unfavorited games from Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ - --pulsate --width=500 --height=150 --auto-close --no-cancel - else - # Remove old entries - steam_sync_remove - fi - # Old manifest cleanup - rm "$retrodeck_favorites_file" - rm "${retrodeck_favorites_file}.new" - else # The new favorites manifest is not empty - if cmp -s "$retrodeck_favorites_file" "${retrodeck_favorites_file}.new"; then # See if the favorites manifests are the same, meaning there were no changes - log i "ES-DE favorites have not changed, no need to sync again" - rm "${retrodeck_favorites_file}.new" - else - log d "New and old manifests are different, running sync" - if [[ -f "$retrodeck_removed_favorites" ]]; then # If some favorites were removed between syncs - log d "Some favorites removed between syncs, removing unfavorited games" - # Load removed favorites as manifest and run SRM remove - mv "$retrodeck_removed_favorites" "$retrodeck_favorites_file" - if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then - ( - steam_sync_remove - ) | - rd_zenity --progress \ - --title="Syncing with Steam" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --text="\t\t\t\tRemoving unfavorited games from Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ - --pulsate --width=500 --height=150 --auto-close --no-cancel - else - steam_sync_remove - fi - fi - if [[ -f "$retrodeck_added_favorites" ]]; then # If some new favorites were added between syncs - log d "Some new favorites added between syncs, adding new favorited games" - # Load added favorites as manifest and run SRM add - mv "$retrodeck_added_favorites" "$retrodeck_favorites_file" - if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then - ( - steam_sync_add - ) | - rd_zenity --progress \ - --title="Syncing with Steam" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --text="\t\t\t\tAdding new favorited games to Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ - --pulsate --width=500 --height=150 --auto-close --no-cancel - else - steam_sync_add - fi - fi - - # Make new favorites manifest the current one - mv "${retrodeck_favorites_file}.new" "$retrodeck_favorites_file" - fi + if [[ -f "$retrodeck_added_favorites" ]]; then # If some new favorites were added between syncs + log d "Some new favorites added between syncs, adding new favorited games" + # Load added favorites as manifest and run SRM add + mv "$retrodeck_added_favorites" "$retrodeck_favorites_file" + steam_sync_add fi - elif [[ "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # No existing favorites manifest was found, so check if new manifest has entries - log d "First time building favorites manifest, running sync" + + # Make new favorites manifest the current one mv "${retrodeck_favorites_file}.new" "$retrodeck_favorites_file" - if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then - ( - # Add new favorites manifest - steam_sync_add - ) | - rd_zenity --progress \ - --title="Syncing with Steam" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --text="\t\t\t\tSyncing favorite games with Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ - --pulsate --width=500 --height=150 --auto-close --no-cancel - else - # Add new favorites manifest - steam_sync_add - fi + fi fi + elif [[ "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # No existing favorites manifest was found, so check if new manifest has entries + log d "First time building favorites manifest, running sync" + mv "${retrodeck_favorites_file}.new" "$retrodeck_favorites_file" + steam_sync_add + fi } steam_sync_add() { + if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then + ( steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 steam-rom-manager add >> "$srm_log" 2>&1 + ) | + rd_zenity --progress \ + --title="Syncing with Steam" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --text="\t\t\t\tAdding new favorited games to Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ + --pulsate --width=500 --height=150 --auto-close --no-cancel + else + steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 + steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 + steam-rom-manager add >> "$srm_log" 2>&1 + fi } steam_sync_remove() { + if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then + ( steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 steam-rom-manager remove >> "$srm_log" 2>&1 + ) | + rd_zenity --progress \ + --title="Syncing with Steam" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --text="\t\t\t\tRemoving unfavorited games from Steam\n\nNOTE: This operation may take some time depending on the size of your library.\nFeel free to leave this in the background and switch to another application.\n\n" \ + --pulsate --width=500 --height=150 --auto-close --no-cancel + else + steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1 + steam-rom-manager enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1 + steam-rom-manager remove >> "$srm_log" 2>&1 + fi } From 79381909a494d9e6ba856d6ac7a1f4b8c339fa6a Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Mar 2025 17:27:19 -0400 Subject: [PATCH 11/15] Add manual sync option and Steam Sync purge options to Zenity Configurator --- tools/configurator.sh | 87 ++++++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 25 deletions(-) diff --git a/tools/configurator.sh b/tools/configurator.sh index 0b694561..d18ce707 100755 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -156,7 +156,7 @@ configurator_welcome_dialog() { ;; "Steam Sync" ) - configurator_steam_sync + configurator_steam_sync_dialog ;; "Developer Options" ) @@ -1217,32 +1217,71 @@ configurator_about_retrodeck_dialog() { esac } -configurator_steam_sync() { - if [[ $(get_setting_value "$rd_conf" "steam_sync" retrodeck "options") == "true" ]]; then - zenity --question \ - --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --title "RetroDECK Configurator - RetroDECK Steam Syncronization" \ - --text="Steam syncronization is currently enabled.\nDisabling Steam Sync will remove all of your favorites from Steam at the next Steam startup.\n\nDo you want to continue?\n\nTo re-add them, just reenable Steam Sync then and restart Steam." +configurator_steam_sync_dialog() { - if [ $? == 0 ] # User clicked "Yes" - then - configurator_disable_steam_sync - else # User clicked "Cancel" - configurator_welcome_dialog - fi - else - zenity --question \ - --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ - --title "RetroDECK Configurator - RetroDECK Steam Syncronization" \ - --text="Steam synchronization is currently disabled. Do you want to enable it?\n\nAll the games marked as favorites will be synchronized with Steam ROM Manager.\nRemember to restart Steam each time to see the changes.\n\nNOTE: games with unusual characters such as '/\{}<>* might break the sync, please refer to the Wiki for more info." + choice=$(rd_zenity --list --title="RetroDECK Configurator Utility - Steam Sync" --cancel-label="Back" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ + --column="Choice" --column="Description" \ + "Enable/Disable Automatic Steam Sync" "Enable or disable automatic Steam Sync, where ES-DE favorites will be synced to Steam when RetroDECK quits." \ + "Manual Steam Sync" "Perform a one-time manual sync of ES-DE favorites to Steam." \ + "Purge Steam Sync Shortcuts" "Perform a full Steam ROM Manager purge of all favorites, in case things have gotten messed up." ) - if [ $? == 0 ] - then - configurator_enable_steam_sync + case $choice in + + "Enable/Disable Automatic Steam Sync" ) + log i "Configurator: opening \"$choice\" menu" + if [[ $(get_setting_value "$rd_conf" "steam_sync" retrodeck "options") == "true" ]]; then + zenity --question \ + --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Configurator - RetroDECK Steam Syncronization" \ + --text="Steam syncronization is currently enabled.\nDisabling Steam Sync will remove all of your favorites from Steam at the next Steam startup.\n\nDo you want to continue?\n\nTo re-add them, just reenable Steam Sync then and restart Steam." + + if [ $? == 0 ] # User clicked "Yes" + then + configurator_disable_steam_sync + fi else - configurator_welcome_dialog + zenity --question \ + --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Configurator - RetroDECK Steam Syncronization" \ + --text="Steam synchronization is currently disabled. Do you want to enable it?\n\nAll the games marked as favorites will be synchronized with Steam ROM Manager.\nRemember to restart Steam each time to see the changes.\n\nNOTE: games with unusual characters such as '/\{}<>* might break the sync, please refer to the Wiki for more info." + + if [ $? == 0 ] + then + configurator_enable_steam_sync + fi fi - fi + configurator_steam_sync_dialog + ;; + + "Manual Steam Sync" ) + log i "Configurator: opening \"$choice\" menu" + export CONFIGURATOR_GUI="zenity" + steam_sync + configurator_steam_sync_dialog + ;; + + "Purge Steam Sync Shortcuts" ) + log i "Configurator: opening \"$choice\" menu" + if [[ $(configurator_generic_question_dialog "RetroDECK Configurator - Steam Sync" "Are you sure you want to remove all Steam ROM Manager changes, including all RetroDECK shortcuts from Steam?" ) == "true" ]]; then + ( + steam-rom-manager nuke + ) | + rd_zenity --progress \ + --title="Removing all RetroDECK Steam Sync information" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --text="\t\t\t\tRemoving all RetroDECK-related data from Steam\n\nPlease wait..." \ + --pulsate --width=500 --height=150 --auto-close --no-cancel + fi + configurator_steam_sync_dialog + ;; + + "" ) # No selection made or Back button clicked + log i "Configurator: going back" + configurator_welcome_dialog + ;; + + esac } configurator_enable_steam_sync() { @@ -1253,7 +1292,6 @@ configurator_enable_steam_sync() { --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Configurator - RetroDECK Steam Syncronization" \ --text="Steam syncronization enabled." - configurator_welcome_dialog } configurator_disable_steam_sync() { @@ -1276,7 +1314,6 @@ configurator_disable_steam_sync() { --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Configurator - RetroDECK Steam Syncronization" \ --text="Steam syncronization disabled and shortcuts removed, restart Steam to apply the changes." - configurator_welcome_dialog } configurator_version_history_dialog() { From c8fc7f3f8ea22d04bb31740e8a7a3f4ec94ecdda Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 27 Mar 2025 12:52:04 -0400 Subject: [PATCH 12/15] Convert /var/config and /var/data paths to XDG environment variables for portability Also fix a ton of improperly-quoted bash variables --- functions/050_save_migration.sh | 70 ++--- functions/checks.sh | 24 +- functions/compression.sh | 12 +- functions/configurator_functions.sh | 6 +- functions/dialogs.sh | 36 +-- functions/framework.sh | 20 +- functions/global.sh | 150 +++++----- functions/multi_user.sh | 86 +++--- functions/other_functions.sh | 102 +++---- functions/post_build_check.sh | 4 +- functions/post_update.sh | 207 +++++++------ functions/prepare_component.sh | 436 ++++++++++++++-------------- functions/presets.sh | 18 +- functions/run_game.sh | 8 +- functions/steam_sync.sh | 2 +- 15 files changed, 590 insertions(+), 591 deletions(-) diff --git a/functions/050_save_migration.sh b/functions/050_save_migration.sh index ae0dc1c3..6d0421bc 100644 --- a/functions/050_save_migration.sh +++ b/functions/050_save_migration.sh @@ -10,7 +10,7 @@ save_migration() { # ROMs on SD card roms_folder="$default_sd/retrodeck/roms" if [[ ! -L "$rdhome" && ! -L "$rdhome/roms" ]]; then # Add a roms folder symlink back to ~/retrodeck if missing, to fix things like PS2 autosaves until user migrates whole ~retrodeck directory - ln -s $roms_folder "$rdhome/roms" + ln -s "$roms_folder" "$rdhome/roms" fi else # ROMs on Internal @@ -31,19 +31,19 @@ save_migration() { fi # Doing the dir prep as we don't know from which version we came - dir_prep "$media_folder" "/var/config/ES-DE/downloaded_media" - dir_prep "$themes_folder" "/var/config/ES-DE/themes" + dir_prep "$media_folder" "$XDG_CONFIG_HOME/ES-DE/downloaded_media" + dir_prep "$themes_folder" "$XDG_CONFIG_HOME/ES-DE/themes" create_dir "$rdhome/logs" #this was added later, maybe safe to remove in a few versions # Resetting es_settings, now we need it but in the future I should think a better solution, maybe with sed - cp -fv /app/retrodeck/es_settings.xml /var/config/ES-DE/settings/es_settings.xml + cp -fv "/app/retrodeck/es_settings.xml" "$XDG_CONFIG_HOME/ES-DE/settings/es_settings.xml" # 0.4 -> 0.5 # Perform save and state migration if needed # Moving PCSX2 Saves - mv -fv /var/config/PCSX2/sstates/* "$rdhome/states/ps2/pcsx2" - mv -fv /var/config/PCSX2/memcards/* "$rdhome/saves/ps2/memcards" + mv -fv "$XDG_CONFIG_HOME/PCSX2/sstates/"* "$rdhome/states/ps2/pcsx2" + mv -fv "$XDG_CONFIG_HOME/PCSX2/memcards/"* "$rdhome/saves/ps2/memcards" # Moving Citra saves from legacy location to 0.5.0b structure @@ -52,7 +52,7 @@ save_migration() { versionwheresaveschanged="0.4.5b" # Hardcoded break point between unsorted and sorted saves - if [[ $(sed -e "s/\.//g" <<< $hard_version) > $(sed -e "s/\.//g" <<< $versionwheresaveschanged) ]] && [[ ! $(sed -e "s/\.//g" <<< $version) > $(sed -e "s/\.//g" <<< $versionwheresaveschanged) ]]; then # Check if user is upgrading from the version where save organization was changed. Try not to reuse this, it things 0.4.5b is newer than 0.4.5 + if [[ $(sed -e "s/\.//g" <<< "$hard_version") > $(sed -e "s/\.//g" <<< "$versionwheresaveschanged") ]] && [[ ! $(sed -e "s/\.//g" <<< "$version") > $(sed -e "s/\.//g" <<< "$versionwheresaveschanged") ]]; then # Check if user is upgrading from the version where save organization was changed. Try not to reuse this, it things 0.4.5b is newer than 0.4.5 migration_logfile="$rdhome/logs/savemove_$(date +"%Y_%m_%d_%I_%M_%p").log" save_backup_file="$rdhome/savebackup_$(date +"%Y_%m_%d_%I_%M_%p").zip" state_backup_file="$rdhome/statesbackup_$(date +"%Y_%m_%d_%I_%M_%p").zip" @@ -74,16 +74,16 @@ save_migration() { current_dest_folder= gamestoskip= - tar -C "$rdhome" -czf $save_backup_file saves # Backup save directory for safety - log i "Saves backed up to" $save_backup_file $migration_logfile - tar -C "$rdhome" -czf $state_backup_file states # Backup state directory for safety - log i "States backed up to" $state_backup_file $migration_logfile + tar -C "$rdhome" -czf "$save_backup_file" saves # Backup save directory for safety + log i "Saves backed up to" "$save_backup_file" "$migration_logfile" + tar -C "$rdhome" -czf "$state_backup_file" states # Backup state directory for safety + log i "States backed up to" "$state_backup_file" "$migration_logfile" ( movefile() { # Take matching save and rom files and sort save into appropriate system folder echo "# $filesleft $currentlybeingmoved remaining..." # These lines update the Zenity progress bar progress=$(( 100 - (( 100 / "$totalfiles" ) * "$filesleft" ))) - echo $progress + echo "$progress" filesleft=$((filesleft-1)) if [[ ! " ${gamestoskip[*]} " =~ " ${1} " ]]; then # If the current game name exists multiple times in array ie. /roms/snes/Mortal Kombat 3.zip and /roms/genesis/Mortal Kombat 3.zip, skip and alert user to sort manually game=$(sed -e "s/\^/ /g" <<< "$1") # Remove whitespace placeholder @@ -91,59 +91,59 @@ save_migration() { systemdir="$(basename "$(dirname "$1")")" # Extract parent directory identifying system ROM belongs to matches=($(find "$roms_folder" -maxdepth 2 -mindepth 2 -name "$gamebasename"".*" | sed -e 's/ /^/g' | sed -e 's/\..*//')) # Search for multiple instances of pure game name, adding to skip list if found if [[ ${#matches[@]} -gt 1 ]]; then - echo "ERROR: Multiple ROMS found with name:" $gamebasename "Please sort saves and states for these ROMS manually" >> $migration_logfile + echo "ERROR: Multiple ROMS found with name: $gamebasename Please sort saves and states for these ROMS manually" >> "$migration_logfile" gamestoskip+=("$1") return fi - log i "Examining ROM file:" "$game" $migration_logfile - log i "System detected as" $systemdir $migration_logfile + log i "Examining ROM file:" "$game" "$migration_logfile" + log i "System detected as" "$systemdir" "$migration_logfile" sosfile=$(sed -e "s/\^/ /g" <<< "$2") # Remove whitespace placeholder from s-ave o-r s-tate file sospurebasename="$(basename "$sosfile")" # Extract pure file name ie. /saves/game1.sav becomes game1 - log i "Current save or state being examined for match:" $sosfile $migration_logfile - log i "Matching save or state" $sosfile "and game" $game "found." $migration_logfile - log i "Moving save or state to $current_dest_folder/$systemdir/$sosbasename" $migration_logfile + log i "Current save or state being examined for match:" "$sosfile" "$migration_logfile" + log i "Matching save or state $sosfile and game $game found." "$migration_logfile" + log i "Moving save or state to $current_dest_folder/$systemdir/$sosbasename" "$migration_logfile" if [[ ! -d $current_dest_folder"/"$systemdir ]]; then # If system directory doesn't exist for save yet, create it log w "Creating missing system directory $current_dest_folder/$systemdir" - mkdir $current_dest_folder/$systemdir + mkdir "$current_dest_folder/$systemdir" fi - mv "$sosfile" -t $current_dest_folder/$systemdir # Move save to appropriate system directory + mv "$sosfile" -t "$current_dest_folder/$systemdir" # Move save to appropriate system directory return else local name="$(basename "$1" | sed -e "s/\^/ /g")" - log w "Game with name \"$name\" already found. Skipping to next game..." $migration_logfile # Inform user of game being skipped due to duplicate ROM names + log w "Game with name \"$name\" already found. Skipping to next game..." "$migration_logfile" # Inform user of game being skipped due to duplicate ROM names fi } - find "$roms_folder" -mindepth 2 -maxdepth 2 -name "*\^*" -exec echo "ERROR: Game named" {} "found, please move save manually" \; >> $migration_logfile # Warn user if any of their files have the whitespace replacement character used by the script + find "$roms_folder" -mindepth 2 -maxdepth 2 -name "*\^*" -exec echo "ERROR: Game named" {} "found, please move save manually" \; >> "$migration_logfile" # Warn user if any of their files have the whitespace replacement character used by the script - totalfiles=$totalsaves #set variables for save file migration - filesleft=$totalsaves + totalfiles="$totalsaves" #set variables for save file migration + filesleft="$totalsaves" currentlybeingmoved="saves" - current_dest_folder=$saves_folder + current_dest_folder="$saves_folder" for i in "${allsaves[@]}"; do # For each save file, compare to every ROM file name looking for a match found= currentsave=($(basename "$i" | sed -e 's/\..*//')) # Extract pure file name ie. /saves/game1.sav becomes game1 for j in "${allgames[@]}"; do currentgame=($(basename "$j" | sed -e 's/\..*//')) # Extract pure file name ie. /roms/snes/game1.zip becomes game1 - [[ $currentgame == $currentsave ]] && { found=1; break; } # If names match move to next stage, otherwise skip + [[ "$currentgame" == "$currentsave" ]] && { found=1; break; } # If names match move to next stage, otherwise skip done - [[ -n $found ]] && movefile $j $i || echo "ERROR: No ROM match found for save file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded save file + [[ -n "$found" ]] && movefile "$j" "$i" || echo "ERROR: No ROM match found for save file" "$i" | sed -e 's/\^/ /g' >> "$migration_logfile" # If a match is found, run movefile() otherwise warn user of stranded save file done - totalfiles=$totalstates #set variables for state file migration - filesleft=$totalstates + totalfiles="$totalstates" #set variables for state file migration + filesleft="$totalstates" currentlybeingmoved="states" - current_dest_folder=$states_folder + current_dest_folder="$states_folder" for i in "${allstates[@]}"; do # For each state file, compare to every ROM file name looking for a match found= currentstate=($(basename "$i" | sed -e 's/\..*//')) # Extract pure file name ie. /states/game1.sav becomes game1 for j in "${allgames[@]}"; do currentgame=($(basename "$j" | sed -e 's/\..*//')) # Extract pure file name ie. /roms/snes/game1.zip becomes game1 - [[ $currentgame == $currentstate ]] && { found=1; break; } # If names match move to next stage, otherwise skip + [[ "$currentgame" == "$currentstate" ]] && { found=1; break; } # If names match move to next stage, otherwise skip done - [[ -n $found ]] && movefile $j $i || echo "ERROR: No ROM match found for state file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded state file + [[ -n "$found" ]] && movefile "$j" "$i" || echo "ERROR: No ROM match found for state file" "$i" | sed -e 's/\^/ /g' >> "$migration_logfile" # If a match is found, run movefile() otherwise warn user of stranded state file done ) | @@ -156,18 +156,18 @@ save_migration() { --no-cancel \ --auto-close - if [[ $(cat $migration_logfile | grep "ERROR" | wc -l) -eq 0 ]]; then + if [[ $(cat "$migration_logfile" | grep "ERROR" | wc -l) -eq 0 ]]; then rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK" \ --text="The migration process has sorted all of your files automatically.\n\nEverything should be working normally, if you experience any issues please check the RetroDECK wiki or contact us directly on the Discord." else - cat $migration_logfile | grep "ERROR" > "$rdhome/manual_sort_needed.log" + cat "$migration_logfile" | grep "ERROR" > "$rdhome/manual_sort_needed.log" rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK" \ - --text="The migration process was unable to sort $(cat $migration_logfile | grep "ERROR" | wc -l) files automatically.\n\nThese files will need to be moved manually to their new locations, find more detail on the RetroDECK wiki.\n\nA log of the files that need manual sorting can be found at $rdhome/manual_sort_needed.log" + --text="The migration process was unable to sort $(cat "$migration_logfile" | grep "ERROR" | wc -l) files automatically.\n\nThese files will need to be moved manually to their new locations, find more detail on the RetroDECK wiki.\n\nA log of the files that need manual sorting can be found at $rdhome/manual_sort_needed.log" fi else diff --git a/functions/checks.sh b/functions/checks.sh index eaee11bd..07255283 100644 --- a/functions/checks.sh +++ b/functions/checks.sh @@ -4,11 +4,11 @@ check_network_connectivity() { # This function will do a basic check for network availability and return "true" if it is working. # USAGE: if [[ $(check_network_connectivity) == "true" ]]; then - if [[ ! -z $(wget --spider -t 1 $remote_network_target_1 | grep "HTTP response 200") ]]; then + if [[ ! -z $(wget --spider -t 1 "$remote_network_target_1" | grep "HTTP response 200") ]]; then local network_connected="true" - elif [[ ! -z $(wget --spider -t 1 $remote_network_target_2 | grep "HTTP response 200") ]]; then + elif [[ ! -z $(wget --spider -t 1 "$remote_network_target_2" | grep "HTTP response 200") ]]; then local network_connected="true" - elif [[ ! -z $(wget --spider -t 1 $remote_network_target_3 | grep "HTTP response 200") ]]; then + elif [[ ! -z $(wget --spider -t 1 "$remote_network_target_3" | grep "HTTP response 200") ]]; then local network_connected="true" else local network_connected="false" @@ -21,7 +21,7 @@ check_desktop_mode() { # This function will do a basic check of if we are running in Steam Deck game mode or not, and return "true" if we are outside of game mode # USAGE: if [[ $(check_desktop_mode) == "true" ]]; then - if [[ ! $XDG_CURRENT_DESKTOP == "gamescope" ]]; then + if [[ ! "$XDG_CURRENT_DESKTOP" == "gamescope" ]]; then echo "true" else echo "false" @@ -32,7 +32,7 @@ check_is_steam_deck() { # This function will check the internal product ID for the Steam Deck codename and return "true" if RetroDECK is running on a real Deck # USAGE: if [[ $(check_is_steam_deck) == "true" ]]; then - if [[ $(cat /sys/devices/virtual/dmi/id/product_name) =~ ^(Jupiter|Galileo)$ ]]; then + if [[ $(cat "/sys/devices/virtual/dmi/id/product_name") =~ ^(Jupiter|Galileo)$ ]]; then echo "true" else echo "false" @@ -58,7 +58,7 @@ check_for_version_update() { fi if [[ ! "$update_ignore" == "$online_version" ]]; then - if [[ "$update_repo" == "RetroDECK" ]] && [[ $(sed -e 's/[\.a-z]//g' <<< $version) -le $(sed -e 's/[\.a-z]//g' <<< $online_version) ]]; then + if [[ "$update_repo" == "RetroDECK" ]] && [[ $(sed -e 's/[\.a-z]//g' <<< "$version") -le $(sed -e 's/[\.a-z]//g' <<< "$online_version") ]]; then choice=$(rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="OK" --extra-button="Ignore this version" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK - New Update Available" \ @@ -66,7 +66,7 @@ check_for_version_update() { rc=$? # Capture return code, as "OK" button has no text value if [[ $rc == "1" ]]; then # If any button other than "OK" was clicked log i "Selected: \"OK\"" - set_setting_value $rd_conf "update_ignore" "$online_version" retrodeck "options" # Store version to ignore for future checks + set_setting_value "$rd_conf" "update_ignore" "$online_version" retrodeck "options" # Store version to ignore for future checks fi elif [[ "$update_repo" == "$cooker_repository_name" ]] && [[ ! $version == $online_version ]]; then log i "Showing update request dialog as \"$online_version\" was found and is greater then \"$version\"" @@ -78,10 +78,10 @@ check_for_version_update() { if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked if [[ $choice == "Ignore this version" ]]; then log i "\"Ignore this version\" selected, updating \"$rd_conf\"" - set_setting_value $rd_conf "update_ignore" "$online_version" retrodeck "options" # Store version to ignore for future checks. + set_setting_value "$rd_conf" "update_ignore" "$online_version" retrodeck "options" # Store version to ignore for future checks. fi else # User clicked "Yes" - install_release $online_version + install_release "$online_version" fi fi fi @@ -93,13 +93,13 @@ check_for_version_update() { validate_input() { while IFS="^" read -r input action || [[ -n "$input" ]]; do - if [[ ! $input == "#"* ]] && [[ ! -z "$input" ]]; then + if [[ ! "$input" == "#"* ]] && [[ ! -z "$input" ]]; then if [[ "$input" == "$1" ]]; then eval "$action" input_validated="true" fi fi - done < $input_validation + done < "$input_validation" } check_version_is_older_than() { @@ -135,7 +135,7 @@ fi # Perform post_update commands for current version if it is a cooker or PR if grep -qF "cooker" <<< "$hard_version" || grep -qF "PR" <<< "$hard_version"; then # If newly-installed version is a "cooker" or "PR" build, always perform post_update commands for current version - if [[ "$(echo $hard_version | cut -d'-' -f2)" == "$new_version" ]]; then + if [[ "$(echo "$hard_version" | cut -d'-' -f2)" == "$new_version" ]]; then is_newer_version="true" fi fi diff --git a/functions/compression.sh b/functions/compression.sh index 4482df47..5a597e42 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -63,10 +63,10 @@ find_compatible_compression_format() { local system=$(echo "$1" | grep -oE "$roms_folder/[^/]+" | grep -oE "[^/]+$") # Extract the relevant lists from the JSON file - local chd_systems=$(jq -r '.compression_targets.chd[]' $features) - local rvz_systems=$(jq -r '.compression_targets.rvz[]' $features) - local zip_systems=$(jq -r '.compression_targets.zip[]' $features) - local zip_compressable_extensions=$(jq -r '.zip_compressable_extensions[]' $features) + local chd_systems=$(jq -r '.compression_targets.chd[]' "$features") + local rvz_systems=$(jq -r '.compression_targets.rvz[]' "$features") + local zip_systems=$(jq -r '.compression_targets.zip[]' "$features") + local zip_compressable_extensions=$(jq -r '.zip_compressable_extensions[]' "$features") if [[ $(validate_for_chd "$1") == "true" ]] && echo "$chd_systems" | grep -q "\b$system\b"; then echo "chd" @@ -259,9 +259,9 @@ cli_compress_all_games() { local compressable_game="" local all_compressable_games=() if [[ $compression_format == "all" ]]; then - local compressible_systems_list=$(jq -r '.compression_targets | to_entries[] | .value[]' $features) + local compressible_systems_list=$(jq -r '.compression_targets | to_entries[] | .value[]' "$features") else - local compressible_systems_list=$(jq -r '.compression_targets["'"$compression_format"'"][]' $features) + local compressible_systems_list=$(jq -r '.compression_targets["'"$compression_format"'"][]' "$features") fi read -p "Do you want to have the original files removed after compression is complete? Please answer y/n and press Enter: " post_compression_cleanup diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh index 78dd78bb..c7a3d5a6 100644 --- a/functions/configurator_functions.sh +++ b/functions/configurator_functions.sh @@ -51,13 +51,13 @@ find_empty_rom_folders() { } configurator_check_multifile_game_structure() { - local folder_games=($(find $roms_folder -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3")) + local folder_games=($(find "$roms_folder" -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3")) if [[ ${#folder_games[@]} -gt 1 ]]; then - echo "$(find $roms_folder -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3")" > $logs_folder/multi_file_games_"$(date +"%Y_%m_%d_%I_%M_%p").log" + echo "$(find "$roms_folder" -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3")" > "$logs_folder"/multi_file_games_"$(date +"%Y_%m_%d_%I_%M_%p").log" rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Configurator - Verify Multi-file Structure" \ - --text="The following games were found to have the incorrect folder structure:\n\n$(find $roms_folder -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3")\n\nIncorrect folder structure can result in failure to launch games or saves being in the incorrect location.\n\nPlease see the RetroDECK wiki for more details!\n\nYou can find this list of games in ~/retrodeck/logs" + --text="The following games were found to have the incorrect folder structure:\n\n$(find "$roms_folder" -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3")\n\nIncorrect folder structure can result in failure to launch games or saves being in the incorrect location.\n\nPlease see the RetroDECK wiki for more details!\n\nYou can find this list of games in ~/retrodeck/logs" else configurator_generic_dialog "RetroDECK Configurator - Verify Multi-file Structure" "No incorrect multi-file game folder structures found." fi diff --git a/functions/dialogs.sh b/functions/dialogs.sh index 6e1a5670..56d3be0a 100644 --- a/functions/dialogs.sh +++ b/functions/dialogs.sh @@ -65,7 +65,7 @@ configurator_destination_choice_dialog() { if [[ $rc == "0" ]] && [[ -z "$choice" ]]; then echo "Back" else - echo $choice + echo "$choice" fi } @@ -88,7 +88,7 @@ configurator_move_folder_dialog() { # USAGE: configurator_move_folder_dialog "folder_variable_name" local rd_dir_name="$1" # The folder variable name from retrodeck.cfg local dir_to_move="$(get_setting_value "$rd_conf" "$rd_dir_name" "retrodeck" "paths")/" # The path of that folder variable - local source_root="$(echo $dir_to_move | sed -e 's/\(.*\)\/retrodeck\/.*/\1/')" # The root path of the folder, excluding retrodeck/. So /home/deck/retrodeck/roms becomes /home/deck + local source_root="$(echo "$dir_to_move" | sed -e 's/\(.*\)\/retrodeck\/.*/\1/')" # The root path of the folder, excluding retrodeck/. So /home/deck/retrodeck/roms becomes /home/deck if [[ ! "$rd_dir_name" == "rdhome" ]]; then # If a sub-folder is being moved, find it's path without the source_root. So /home/deck/retrodeck/roms becomes retrodeck/roms local rd_dir_path="$(echo "$dir_to_move" | sed "s/.*\(retrodeck\/.*\)/\1/; s/\/$//")" else # Otherwise just set the retrodeck root folder @@ -114,7 +114,7 @@ configurator_move_folder_dialog() { configurator_generic_dialog "RetroDECK Configurator - Move Folder" "The $(basename "$dir_to_move") folder is already at that location, please pick a new one." configurator_move_folder_dialog "$rd_dir_name" else - if [[ $(verify_space "$(echo $dir_to_move | sed 's/\/$//')" "$dest_root") ]]; then # Make sure there is enough space at the destination + if [[ $(verify_space "$(echo "$dir_to_move" | sed 's/\/$//')" "$dest_root") ]]; then # Make sure there is enough space at the destination configurator_generic_dialog "RetroDECK Configurator - Move Folder" "Moving $(basename "$dir_to_move") folder to $choice" unlink "$dest_root/$rd_dir_path" # In case there is already a symlink at the picked destination move "$dir_to_move" "$dest_root/$rd_dir_path" @@ -168,28 +168,28 @@ changelog_dialog() { log d "Showing changelog dialog" if [[ "$1" == "all" ]]; then - > "/var/config/retrodeck/changelog-full.xml" - for release in $(xml sel -t -m "//component/releases/release" -v "@version" -n $rd_metainfo); do - echo "

RetroDECK v$release

" >> "/var/config/retrodeck/changelog-full.xml" - xml sel -t -m "//component/releases/release[@version='$release']/description" -c . $rd_metainfo | tr -s '\n' | sed 's/^\s*//' >> "/var/config/retrodeck/changelog-full.xml" - echo "" >> "/var/config/retrodeck/changelog-full.xml" + > "$XDG_CONFIG_HOME/retrodeck/changelog-full.xml" + for release in $(xml sel -t -m "//component/releases/release" -v "@version" -n "$rd_metainfo"); do + echo "

RetroDECK v$release

" >> "$XDG_CONFIG_HOME/retrodeck/changelog-full.xml" + xml sel -t -m "//component/releases/release[@version='"$release"']/description" -c . "$rd_metainfo" | tr -s '\n' | sed 's/^\s*//' >> "$XDG_CONFIG_HOME/retrodeck/changelog-full.xml" + echo "" >> "$XDG_CONFIG_HOME/retrodeck/changelog-full.xml" done - #convert_to_markdown "/var/config/retrodeck/changelog-full.xml" + #convert_to_markdown "$XDG_CONFIG_HOME/retrodeck/changelog-full.xml" rd_zenity --icon-name=net.retrodeck.retrodeck --text-info --width=1200 --height=720 \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Changelogs" \ - --filename="/var/config/retrodeck/changelog-full.xml.md" + --filename="$XDG_CONFIG_HOME/retrodeck/changelog-full.xml.md" else - xml sel -t -m "//component/releases/release[@version='$1']/description" -c . $rd_metainfo | tr -s '\n' | sed 's/^\s*//' > "/var/config/retrodeck/changelog.xml" + xml sel -t -m "//component/releases/release[@version='"$1"']/description" -c . "$rd_metainfo" | tr -s '\n' | sed 's/^\s*//' > "$XDG_CONFIG_HOME/retrodeck/changelog.xml" - convert_to_markdown "/var/config/retrodeck/changelog.xml" + convert_to_markdown "$XDG_CONFIG_HOME/retrodeck/changelog.xml" rd_zenity --icon-name=net.retrodeck.retrodeck --text-info --width=1200 --height=720 \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Changelogs" \ - --filename="/var/config/retrodeck/changelog.xml.md" + --filename="$XDG_CONFIG_HOME/retrodeck/changelog.xml.md" fi } @@ -204,9 +204,9 @@ get_cheevos_token_dialog() { --add-password="Password") IFS='^' read -r cheevos_username cheevos_password < <(printf '%s\n' "$cheevos_info") - local cheevos_response=$(curl --silent --data "r=login&u=$cheevos_username&p=$cheevos_password" $RA_API_URL) - local cheevos_success=$(echo $cheevos_response | jq .Success | tr -d '"') - local cheevos_token=$(echo $cheevos_response | jq .Token | tr -d '"') + local cheevos_response=$(curl --silent --data "r=login&u=$cheevos_username&p=$cheevos_password" "$RA_API_URL") + local cheevos_success=$(echo "$cheevos_response" | jq .Success | tr -d '"') + local cheevos_token=$(echo "$cheevos_response" | jq .Token | tr -d '"') local cheevos_login_timestamp=$(date +%s) if [[ "$cheevos_success" == "true" ]]; then echo "$cheevos_username,$cheevos_token,$cheevos_login_timestamp" @@ -235,7 +235,7 @@ desktop_mode_warning() { exit 1 elif [[ $choice == "Never show this again" ]]; then log i "Selected: \"Never show this again\"" - set_setting_value $rd_conf "desktop_mode_warning" "false" retrodeck "options" # Store desktop mode warning variable for future checks + set_setting_value "$rd_conf" "desktop_mode_warning" "false" retrodeck "options" # Store desktop mode warning variable for future checks fi else log i "Selected: \"Yes\"" @@ -258,7 +258,7 @@ low_space_warning() { --text="$message") if [[ $choice == "Never show this again" ]]; then log i "Selected: \"Never show this again\"" - set_setting_value $rd_conf "low_space_warning" "false" retrodeck "options" # Store low space warning variable for future checks + set_setting_value "$rd_conf" "low_space_warning" "false" retrodeck "options" # Store low space warning variable for future checks fi fi log i "Selected: \"OK\"" diff --git a/functions/framework.sh b/functions/framework.sh index ed93dc65..d3463df8 100644 --- a/functions/framework.sh +++ b/functions/framework.sh @@ -141,7 +141,7 @@ get_setting_value() { "dolphin" | "duckstation" | "pcsx2" | "ppsspp" | "primehack" | "xemu" ) # For files with this syntax - setting_name = setting_value if [[ -z $current_section_name ]]; then - echo $(grep -o -P "(?<=^$current_setting_name = ).*" $1) + echo $(grep -o -P "(?<=^$current_setting_name = ).*" "$1") else sed -n -E '\^\['"$current_section_name"'\]^,\^\^'"$current_setting_name"'|\[^{ \^\['"$current_section_name"'\]^! { \^\^'"$current_setting_name"'^ p } }' "$1" | grep -o -P "(?<=^$current_setting_name = ).*" fi @@ -337,7 +337,7 @@ generate_single_patch() { current_setting_name=$(get_setting_name "$escaped_setting_line" "$system") if [[ (-z $(sed -n -E '\^\['"$current_section"'\]|\b'"$current_section"':$^,\^\b'"$current_setting_name"'\s*?[:=]^{ \^\['"$current_section"'\]|\b'"$current_section"':$^! { \^\b'"$(sed -E 's/^[ \t]*//;' <<< "$escaped_setting_line")"'$^ p } }' "$modified_file")) ]]; then # If the same setting line is not found in the same section of the modified file... if [[ ! -z $(sed -n -E '\^\['"$current_section"'\]|\b'"$current_section"':$^,\^\b'"$current_setting_name"'\s*?[:=]^{ \^\['"$current_section"'\]|\b'"$current_section"':$^! { \^\b'"$current_setting_name"'\s*?[:=]^ p } }' "$modified_file") ]]; then # But the setting exists in that section, only with a different value... - new_setting_value=$(get_setting_value "$2" "$current_setting_name" "$system" $current_section) + new_setting_value=$(get_setting_value "$2" "$current_setting_name" "$system" "$current_section") action="change" echo $action"^"$current_section"^"$(sed -e 's%\\\\%\\%g' <<< "$current_setting_name")"^"$new_setting_value"^"$system >> "$patch_file" fi @@ -356,7 +356,7 @@ generate_single_patch() { if [[ (-z $(sed -n -E '\^\s*?\b'"$(sed -E 's/^[ \t]*//' <<< "$escaped_setting_line")"'$^p' "$modified_file")) ]]; then # If the same setting line is not found in the modified file... current_setting_name=$(get_setting_name "$escaped_setting_line" "$system") if [[ ! -z $(sed -n -E '\^\s*?\b'"$current_setting_name"'\s*?[:=]^p' "$modified_file") ]]; then # But the setting exists, only with a different value... - new_setting_value=$(get_setting_value $2 "$current_setting_name" "$system") + new_setting_value=$(get_setting_value "$2" "$current_setting_name" "$system") action="change" echo $action"^"$current_section"^"$(sed -e 's%\\\\%\\%g' <<< "$current_setting_name")"^"$new_setting_value"^"$system >> "$patch_file" fi @@ -381,22 +381,22 @@ generate_single_patch() { if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") || ! -z $(grep -o -P "^\b.+?:$" <<< "$current_setting_line") ]]; then # Capture section header lines if [[ $current_setting_line =~ ^\[.+\] ]]; then # If normal section line action="section" - current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name + current_section=$(sed 's^[][]^^g' <<< "$current_setting_line") # Remove brackets from section name elif [[ ! -z $(grep -o -P "^\b.+?:$" <<< "$current_setting_line") ]]; then # If RPCS3 section name action="section" - current_section=$(sed 's^:$^^' <<< $current_setting_line) # Remove colon from section name + current_section=$(sed 's^:$^^' <<< "$current_setting_line") # Remove colon from section name fi elif [[ (! -z $current_section) ]]; then current_setting_name=$(get_setting_name "$escaped_setting_line" "$4") - if [[ -z $(sed -n -E '\^\['"$current_section"'\]|\b'"$current_section"':$^,\^\b'"$current_setting_name"'.*^{ \^\['"$current_section"'\]|\b'"$current_section"':$^! { \^\b'"$current_setting_name"'^p } }' $1 ) ]]; then # If setting name is not found in this section of the original file... + if [[ -z $(sed -n -E '\^\['"$current_section"'\]|\b'"$current_section"':$^,\^\b'"$current_setting_name"'.*^{ \^\['"$current_section"'\]|\b'"$current_section"':$^! { \^\b'"$current_setting_name"'^p } }' "$1" ) ]]; then # If setting name is not found in this section of the original file... action="add_setting_line" # TODO: This should include the previous line, so that new lines can be inserted in the correct place rather than at the end. - echo $action"^"$current_section"^"$current_setting_line"^^"$4 >> $3 + echo $action"^"$current_section"^"$current_setting_line"^^"$4 >> "$3" fi elif [[ (-z $current_section) ]]; then current_setting_name=$(get_setting_name "$escaped_setting_line" "$4") - if [[ -z $(sed -n -E '\^\s*?\b'"$current_setting_name"'\s*?[:=]^p' $1) ]]; then # If setting name is not found in the original file... + if [[ -z $(sed -n -E '\^\s*?\b'"$current_setting_name"'\s*?[:=]^p' "$1") ]]; then # If setting name is not found in the original file... action="add_setting_line" # TODO: This should include the previous line, so that new lines can be inserted in the correct place rather than at the end. - echo $action"^"$current_section"^"$current_setting_line"^^"$4 >> $3 + echo $action"^"$current_section"^"$current_setting_line"^^"$4 >> "$3" fi fi fi @@ -562,4 +562,4 @@ populate_steamuser_srm(){ ) ' "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json" > "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json.tmp" && mv "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json.tmp" "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json" -} \ No newline at end of file +} diff --git a/functions/global.sh b/functions/global.sh index b2420606..a7d59906 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -7,7 +7,7 @@ # export LD_LIBRARY_PATH="/app/retrodeck/lib:/app/retrodeck/lib/debug:/app/retrodeck/lib/pkgconfig:$LD_LIBRARY_PATH" : "${logging_level:=info}" # Initializing the log level variable if not already valued, this will be actually red later from the config file -rd_logs_folder="/var/config/retrodeck/logs" # Static location to write all RetroDECK-related logs +rd_logs_folder="$XDG_CONFIG_HOME/retrodeck/logs" # Static location to write all RetroDECK-related logs if [ -h "$rd_logs_folder" ]; then # Check if internal logging folder is already a symlink if [ ! -e "$rd_logs_folder" ]; then # Check if internal logging folder symlink is broken unlink "$rd_logs_folder" # Remove broken symlink so the folder is recreated when sourcing logger.sh @@ -55,21 +55,21 @@ source /app/libexec/run_game.sh source /app/libexec/steam_sync.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 +rd_conf="$XDG_CONFIG_HOME/retrodeck/retrodeck.cfg" # RetroDECK config file path +rd_conf_backup="$XDG_CONFIG_HOME/retrodeck/retrodeck.bak" # Backup of RetroDECK config file from update config="/app/retrodeck/config" # folder with all the default emulator configs rd_defaults="$config/retrodeck/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 +rd_update_patch="$XDG_CONFIG_HOME/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates bios_checklist="$config/retrodeck/reference_lists/bios.json" # A config file listing BIOS file information that can be verified input_validation="$config/retrodeck/reference_lists/input_validation.cfg" # A config file listing valid CLI inputs finit_options_list="$config/retrodeck/reference_lists/finit_options_list.cfg" # A config file listing available optional installs during finit -splashscreen_dir="/var/config/ES-DE/resources/graphics/extra_splashes" # The default location of extra splash screens -current_splash_file="/var/config/ES-DE/resources/graphics/splash.svg" # The active splash file that will be shown on boot -default_splash_file="/var/config/ES-DE/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen +splashscreen_dir="$XDG_CONFIG_HOME/ES-DE/resources/graphics/extra_splashes" # The default location of extra splash screens +current_splash_file="$XDG_CONFIG_HOME/ES-DE/resources/graphics/splash.svg" # The active splash file that will be shown on boot +default_splash_file="$XDG_CONFIG_HOME/ES-DE/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen # TODO: instead of this maybe we can iterate the features.json multi_user_emulator_config_dirs="$config/retrodeck/reference_lists/multi_user_emulator_config_dirs.cfg" # A list of emulator config folders that can be safely linked/unlinked entirely in multi-user mode rd_es_themes="/app/share/es-de/themes" # The directory where themes packaged with RetroDECK are stored -lockfile="/var/config/retrodeck/.lock" # Where the lockfile is located +lockfile="$XDG_CONFIG_HOME/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) rd_repo="https://github.com/RetroDECK/RetroDECK" # The URL of the main RetroDECK GitHub repo @@ -91,84 +91,84 @@ es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # Godot data transfer temp files -godot_bios_files_checked="/var/config/retrodeck/godot/godot_bios_files_checked.tmp" -godot_current_preset_settings="/var/config/retrodeck/godot/godot_current_preset_settings.tmp" -godot_compression_compatible_games="/var/config/retrodeck/godot/godot_compression_compatible_games.tmp" -godot_empty_roms_folders="/var/config/retrodeck/godot/godot_empty_roms_folders.tmp" +godot_bios_files_checked="$XDG_CONFIG_HOME/retrodeck/godot/godot_bios_files_checked.tmp" +godot_current_preset_settings="$XDG_CONFIG_HOME/retrodeck/godot/godot_current_preset_settings.tmp" +godot_compression_compatible_games="$XDG_CONFIG_HOME/retrodeck/godot/godot_compression_compatible_games.tmp" +godot_empty_roms_folders="$XDG_CONFIG_HOME/retrodeck/godot/godot_empty_roms_folders.tmp" # Config files for emulators with single config files -duckstationconf="/var/config/duckstation/settings.ini" -melondsconf="/var/config/melonDS/melonDS.ini" -ryujinxconf="/var/config/Ryujinx/Config.json" -xemuconf="/var/config/xemu/xemu.toml" -yuzuconf="/var/config/yuzu/qt-config.ini" -citraconf="/var/config/citra-emu/qt-config.ini" +duckstationconf="$XDG_CONFIG_HOME/duckstation/settings.ini" +melondsconf="$XDG_CONFIG_HOME/melonDS/melonDS.ini" +ryujinxconf="$XDG_CONFIG_HOME/Ryujinx/Config.json" +xemuconf="$XDG_CONFIG_HOME/xemu/xemu.toml" +yuzuconf="$XDG_CONFIG_HOME/yuzu/qt-config.ini" +citraconf="$XDG_CONFIG_HOME/citra-emu/qt-config.ini" # ES-DE config files -export ESDE_APPDATA_DIR="/var/config/ES-DE" -es_settings="/var/config/ES-DE/settings/es_settings.xml" -es_source_logs="/var/config/ES-DE/logs" +export ESDE_APPDATA_DIR="$XDG_CONFIG_HOME/ES-DE" +es_settings="$XDG_CONFIG_HOME/ES-DE/settings/es_settings.xml" +es_source_logs="$XDG_CONFIG_HOME/ES-DE/logs" # RetroArch config files -raconf="/var/config/retroarch/retroarch.cfg" -ra_core_conf="/var/config/retroarch/retroarch-core-options.cfg" -ra_scummvm_conf="/var/config/retroarch/system/scummvm.ini" -ra_cores_path="/var/config/retroarch/cores" +raconf="$XDG_CONFIG_HOME/retroarch/retroarch.cfg" +ra_core_conf="$XDG_CONFIG_HOME/retroarch/retroarch-core-options.cfg" +ra_scummvm_conf="$XDG_CONFIG_HOME/retroarch/system/scummvm.ini" +ra_cores_path="$XDG_CONFIG_HOME/retroarch/cores" # CEMU config files -cemuconf="/var/config/Cemu/settings.xml" -cemucontrollerconf="/var/config/Cemu/controllerProfiles/controller0.xml" +cemuconf="$XDG_CONFIG_HOME/Cemu/settings.xml" +cemucontrollerconf="$XDG_CONFIG_HOME/Cemu/controllerProfiles/controller0.xml" # 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" -dolphinDynamicInputTexturesPath="/var/data/dolphin-emu/Load/DynamicInputTextures" -dolphinCheevosConf="/var/config/dolphin-emu/RetroAchievements.ini" +dolphinconf="$XDG_CONFIG_HOME/dolphin-emu/Dolphin.ini" +dolphingcpadconf="$XDG_CONFIG_HOME/dolphin-emu/GCPadNew.ini" +dolphingfxconf="$XDG_CONFIG_HOME/dolphin-emu/GFX.ini" +dolphinhkconf="$XDG_CONFIG_HOME/dolphin-emu/Hotkeys.ini" +dolphinqtconf="$XDG_CONFIG_HOME/dolphin-emu/Qt.ini" +dolphinDynamicInputTexturesPath="$XDG_DATA_HOME/dolphin-emu/Load/DynamicInputTextures" +dolphinCheevosConf="$XDG_CONFIG_HOME/dolphin-emu/RetroAchievements.ini" # PCSX2 config files -pcsx2conf="/var/config/PCSX2/inis/PCSX2.ini" -pcsx2gsconf="/var/config/PCSX2/inis/GS.ini" # This file should be deprecated since moving to PCSX2-QT -pcsx2uiconf="/var/config/PCSX2/inis/PCSX2_ui.ini" # This file should be deprecated since moving to PCSX2-QT -pcsx2vmconf="/var/config/PCSX2/inis/PCSX2_vm.ini" # This file should be deprecated since moving to PCSX2-QT +pcsx2conf="$XDG_CONFIG_HOME/PCSX2/inis/PCSX2.ini" +pcsx2gsconf="$XDG_CONFIG_HOME/PCSX2/inis/GS.ini" # This file should be deprecated since moving to PCSX2-QT +pcsx2uiconf="$XDG_CONFIG_HOME/PCSX2/inis/PCSX2_ui.ini" # This file should be deprecated since moving to PCSX2-QT +pcsx2vmconf="$XDG_CONFIG_HOME/PCSX2/inis/PCSX2_vm.ini" # This file should be deprecated since moving to PCSX2-QT # PPSSPP-SDL config files -ppssppconf="/var/config/ppsspp/PSP/SYSTEM/ppsspp.ini" -ppssppcontrolsconf="/var/config/ppsspp/PSP/SYSTEM/controls.ini" -ppssppcheevosconf="/var/config/ppsspp/PSP/SYSTEM/ppsspp_retroachievements.dat" +ppssppconf="$XDG_CONFIG_HOME/ppsspp/PSP/SYSTEM/ppsspp.ini" +ppssppcontrolsconf="$XDG_CONFIG_HOME/ppsspp/PSP/SYSTEM/controls.ini" +ppssppcheevosconf="$XDG_CONFIG_HOME/ppsspp/PSP/SYSTEM/ppsspp_retroachievements.dat" # 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" -primehackDynamicInputTexturesPath="/var/data/primehack/Load/DynamicInputTextures" +primehackconf="$XDG_CONFIG_HOME/primehack/Dolphin.ini" +primehackgcpadconf="$XDG_CONFIG_HOME/primehack/GCPadNew.ini" +primehackgfxconf="$XDG_CONFIG_HOME/primehack/GFX.ini" +primehackhkconf="$XDG_CONFIG_HOME/primehack/Hotkeys.ini" +primehackqtconf="$XDG_CONFIG_HOME/primehack/Qt.ini" +primehackDynamicInputTexturesPath="$XDG_DATA_HOME/primehack/Load/DynamicInputTextures" # RPCS3 config files -rpcs3conf="/var/config/rpcs3/config.yml" -rpcs3vfsconf="/var/config/rpcs3/vfs.yml" +rpcs3conf="$XDG_CONFIG_HOME/rpcs3/config.yml" +rpcs3vfsconf="$XDG_CONFIG_HOME/rpcs3/vfs.yml" # Vita3k config files -vita3kconf="/var/config/Vita3K/config.yml" +vita3kconf="$XDG_CONFIG_HOME/Vita3K/config.yml" # MAME-SA config files -mameconf="/var/config/mame/ini/mame.ini" -mameuiconf="/var/config/mame/ini/ui.ini" -mamedefconf="/var/config/mame/cfg/default.cfg" +mameconf="$XDG_CONFIG_HOME/mame/ini/mame.ini" +mameuiconf="$XDG_CONFIG_HOME/mame/ini/ui.ini" +mamedefconf="$XDG_CONFIG_HOME/mame/cfg/default.cfg" # Initialize logging location if it doesn't exist, before anything else happens if [ ! -d "$rd_logs_folder" ]; then @@ -176,13 +176,13 @@ if [ ! -d "$rd_logs_folder" ]; then fi # Initialize location of Godot temp data files, if it doesn't exist -if [[ ! -d "/var/config/retrodeck/godot" ]]; then - create_dir "/var/config/retrodeck/godot" +if [[ ! -d "$XDG_CONFIG_HOME/retrodeck/godot" ]]; then + create_dir "$XDG_CONFIG_HOME/retrodeck/godot" fi -# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions +# We moved the lockfile in $XDG_CONFIG_HOME/retrodeck in order to solve issue #53 - Remove in a few versions if [[ -f "$HOME/retrodeck/.lock" ]]; then - mv "$HOME/retrodeck/.lock" $lockfile + mv "$HOME/retrodeck/.lock" "$lockfile" fi # If there is no config file I initalize the file with the the default values @@ -193,9 +193,9 @@ if [[ ! -f "$rd_conf" ]]; then # Initializing the variables if [[ -z "$version" ]]; then if [[ -f "$lockfile" ]]; then - 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 + 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 log d "Running version workaround" - version=$(cat $lockfile) + version=$(cat "$lockfile") fi else version="$hard_version" @@ -203,28 +203,28 @@ if [[ ! -f "$rd_conf" ]]; then fi # Check if SD card path has changed from SteamOS update - if [[ ! -d "$default_sd" && "$(ls -A /run/media/deck/)" ]]; then - if [[ $(find /run/media/deck/* -maxdepth 0 -type d -print | wc -l) -eq 1 ]]; then # If there is only one SD card found in the new SteamOS 3.5 location, assign it as the default - default_sd="$(find /run/media/deck/* -maxdepth 0 -type d -print)" + if [[ ! -d "$default_sd" && "$(ls -A "/run/media/deck/")" ]]; then + if [[ $(find "/run/media/deck/"* -maxdepth 0 -type d -print | wc -l) -eq 1 ]]; then # If there is only one SD card found in the new SteamOS 3.5 location, assign it as the default + default_sd="$(find "/run/media/deck/"* -maxdepth 0 -type d -print)" else # If the default legacy path cannot be found, and there are multiple entries in the new Steam OS 3.5 SD card path, let the user pick which one to use configurator_generic_dialog "RetroDECK Setup" "The SD card was not found in the default location, and multiple drives were detected.\nPlease browse to the location of the desired SD card.\n\nIf you are not using an SD card, please click \"Cancel\"." default_sd="$(directory_browse "SD Card Location")" fi fi - cp $rd_defaults $rd_conf # Load default settings file - set_setting_value $rd_conf "version" "$version" retrodeck # Set current version for new installs - set_setting_value $rd_conf "sdcard" "$default_sd" retrodeck "paths" # Set SD card location if default path has changed + cp "$rd_defaults" "$rd_conf" # Load default settings file + set_setting_value "$rd_conf" "version" "$version" retrodeck # Set current version for new installs + set_setting_value "$rd_conf" "sdcard" "$default_sd" retrodeck "paths" # Set SD card location if default path has changed if grep -qF "cooker" <<< "$hard_version" || grep -qF "PR-" <<< "$hard_version"; then # If newly-installed version is a "cooker" or PR build - set_setting_value $rd_conf "update_repo" "$cooker_repository_name" retrodeck "options" - set_setting_value $rd_conf "update_check" "true" retrodeck "options" - set_setting_value $rd_conf "developer_options" "true" retrodeck "options" + set_setting_value "$rd_conf" "update_repo" "$cooker_repository_name" retrodeck "options" + set_setting_value "$rd_conf" "update_check" "true" retrodeck "options" + set_setting_value "$rd_conf" "developer_options" "true" retrodeck "options" fi log i "Setting config file permissions" - chmod +rw $rd_conf - log i "RetroDECK config file initialized. Contents:\n\n$(cat $rd_conf)\n" + chmod +rw "$rd_conf" + log i "RetroDECK config file initialized. Contents:\n\n$(cat "$rd_conf")\n" conf_read # Load new variables into memory #tmplog_merger # This function is tempry(?) removed @@ -232,10 +232,10 @@ if [[ ! -f "$rd_conf" ]]; then else log i "Loading RetroDECK config file in $rd_conf" - if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build - set_setting_value $rd_conf "update_repo" "$cooker_repository_name" retrodeck "options" - set_setting_value $rd_conf "update_check" "true" retrodeck "options" - set_setting_value $rd_conf "developer_options" "true" retrodeck "options" + if grep -qF "cooker" <<< "$hard_version"; then # If newly-installed version is a "cooker" build + set_setting_value "$rd_conf" "update_repo" "$cooker_repository_name" retrodeck "options" + set_setting_value "$rd_conf" "update_check" "true" retrodeck "options" + set_setting_value "$rd_conf" "developer_options" "true" retrodeck "options" fi conf_read @@ -244,7 +244,7 @@ else if [[ ! -d "$rdhome" ]]; then configurator_generic_dialog "RetroDECK Setup" "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." new_home_path=$(directory_browse "RetroDECK folder location") - set_setting_value $rd_conf "rdhome" "$new_home_path" retrodeck "paths" + set_setting_value "$rd_conf" "rdhome" "$new_home_path" retrodeck "paths" conf_read #tmplog_merger # This function is tempry(?) removed prepare_component "postmove" "retrodeck" diff --git a/functions/multi_user.sh b/functions/multi_user.sh index d18e220d..ab9fd01a 100644 --- a/functions/multi_user.sh +++ b/functions/multi_user.sh @@ -8,11 +8,11 @@ multi_user_set_default_dialog() { --text="Would you like to set $chosen_user as the default user?\n\nIf the current user cannot be determined from the system, the default will be used.\nThis normally only happens in Desktop Mode.\n\nIf you would like to be asked which user is playing every time, click \"No and don't ask again\"") rc=$? # Capture return code, as "Yes" button has no text value if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked - if [[ $choice == "No and don't ask again" ]]; then - set_setting_value $rd_conf "ask_default_user" "false" retrodeck "options" + if [[ "$choice" == "No and don't ask again" ]]; then + set_setting_value "$rd_conf" "ask_default_user" "false" retrodeck "options" fi else # User clicked "Yes" - set_setting_value $rd_conf "default_user" "$chosen_user" retrodeck "options" + set_setting_value "$rd_conf" "default_user" "$chosen_user" retrodeck "options" fi } @@ -30,7 +30,7 @@ chosen_user=$(rd_zenity \ --column "Steam Username" --print-column=1 \ "${full_userlist[@]}") -if [[ ! -z $chosen_user && -z $default_user && $ask_default_user == "true" ]]; then +if [[ ! -z "$chosen_user" && -z "$default_user" && "$ask_default_user" == "true" ]]; then multi_user_set_default_dialog "$chosen_user" fi echo "$chosen_user" @@ -48,7 +48,7 @@ multi_user_enable_multi_user_mode() { rm -rf "$multi_user_data_folder/$SteamAppUser" # Remove stale data after backup fi fi - set_setting_value $rd_conf "multi_user_mode" "true" retrodeck "options" + set_setting_value "$rd_conf" "multi_user_mode" "true" retrodeck "options" multi_user_determine_current_user if [[ -d "$multi_user_data_folder/$SteamAppUser" ]]; then configurator_process_complete_dialog "enabling multi-user support" @@ -74,7 +74,7 @@ multi_user_disable_multi_user_mode() { if [[ ! -z "$single_user" ]]; then # Single user was selected multi_user_return_to_single_user "$single_user" - set_setting_value $rd_conf "multi_user_mode" "false" retrodeck "options" + set_setting_value "$rd_conf" "multi_user_mode" "false" retrodeck "options" configurator_process_complete_dialog "disabling multi-user support" else configurator_generic_dialog "RetroDECK Multi-User Mode" "No single user was selected, please try the process again." @@ -83,13 +83,13 @@ multi_user_disable_multi_user_mode() { else single_user=$(ls -1 "$multi_user_data_folder") multi_user_return_to_single_user "$single_user" - set_setting_value $rd_conf "multi_user_mode" "false" retrodeck "options" + set_setting_value "$rd_conf" "multi_user_mode" "false" retrodeck "options" configurator_process_complete_dialog "disabling multi-user support" fi } multi_user_determine_current_user() { - if [[ $(get_setting_value $rd_conf "multi_user_mode" retrodeck "options") == "true" ]]; then # If multi-user environment is enabled in rd_conf + if [[ $(get_setting_value "$rd_conf" "multi_user_mode" retrodeck "options") == "true" ]]; then # If multi-user environment is enabled in rd_conf if [[ -d "$multi_user_data_folder" ]]; then if [[ ! -z $SteamAppUser ]]; then # If running in Game Mode and this variable exists if [[ -z $(ls -1 "$multi_user_data_folder" | grep "$SteamAppUser") ]]; then @@ -99,24 +99,24 @@ multi_user_determine_current_user() { fi else # Unable to find Steam user ID if [[ $(ls -1 "$multi_user_data_folder" | wc -l) -gt 1 ]]; then - if [[ -z $default_user ]]; then # And a default user is not set + if [[ -z "$default_user" ]]; then # And a default user is not set configurator_generic_dialog "RetroDECK Multi-User Mode" "The current user could not be determined from the system, and there are multiple users registered.\n\nPlease select which user is currently playing in the next dialog." SteamAppUser=$(multi_user_choose_current_user_dialog) - if [[ ! -z $SteamAppUser ]]; then # User was chosen from dialog + if [[ ! -z "$SteamAppUser" ]]; then # User was chosen from dialog multi_user_link_current_user_files else configurator_generic_dialog "RetroDECK Multi-User Mode" "No user was chosen, RetroDECK will launch with the files from the user who played most recently." fi else # The default user is set - if [[ ! -z $(ls -1 $multi_user_data_folder | grep "$default_user") ]]; then # Confirm user data folder exists - SteamAppUser=$default_user + if [[ ! -z $(ls -1 "$multi_user_data_folder" | grep "$default_user") ]]; then # Confirm user data folder exists + SteamAppUser="$default_user" multi_user_link_current_user_files else # Default user has no data folder, something may have gone horribly wrong. Setting up as a new user. multi_user_setup_new_user fi fi else # If there is only 1 user in the userlist, default to that user - SteamAppUser=$(ls -1 $multi_user_data_folder) + SteamAppUser=$(ls -1 "$multi_user_data_folder") multi_user_link_current_user_files fi fi @@ -134,11 +134,11 @@ multi_user_determine_current_user() { multi_user_setup_new_user else # But dialog box was blank configurator_generic_dialog "RetroDECK Multi-User Mode" "No username was entered, so multi-user data folder cannot be created.\n\nDisabling multi-user mode, please try the process again." - set_setting_value $rd_conf "multi_user_mode" "false" retrodeck "options" + set_setting_value "$rd_conf" "multi_user_mode" "false" retrodeck "options" fi else # User clicked "Cancel" configurator_generic_dialog "RetroDECK Multi-User Mode" "Cancelling multi-user mode activation." - set_setting_value $rd_conf "multi_user_mode" "false" retrodeck "options" + set_setting_value "$rd_conf" "multi_user_mode" "false" retrodeck "options" fi fi fi @@ -155,16 +155,16 @@ multi_user_return_to_single_user() { unlink "$rd_conf" mv -f "$multi_user_data_folder/$SteamAppUser/config/retrodeck/retrodeck.cfg" "$rd_conf" # RetroArch one-offs, because it has so many folders that should be shared between users - unlink "/var/config/retroarch/retroarch.cfg" - unlink "/var/config/retroarch/retroarch-core-options.cfg" - mv -f "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" "/var/config/retroarch/retroarch.cfg" - mv -f "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" "/var/config/retroarch/retroarch-core-options.cfg" - # XEMU one-offs, because it stores its config in /var/data, not /var/config like everything else - unlink "/var/config/xemu" - unlink "/var/data/xemu/xemu" - create_dir "/var/config/xemu" - mv -f "$multi_user_data_folder/$single_user/config/xemu"/{.[!.],}* "/var/config/xemu" - dir_prep "/var/config/xemu" "/var/data/xemu/xemu" + unlink "$XDG_CONFIG_HOME/retroarch/retroarch.cfg" + unlink "$XDG_CONFIG_HOME/retroarch/retroarch-core-options.cfg" + mv -f "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" "$XDG_CONFIG_HOME/retroarch/retroarch.cfg" + mv -f "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" "$XDG_CONFIG_HOME/retroarch/retroarch-core-options.cfg" + # XEMU one-offs, because it stores its config in $XDG_DATA_HOME, not $XDG_CONFIG_HOME like everything else + unlink "$XDG_CONFIG_HOME/xemu" + unlink "$XDG_DATA_HOME/xemu/xemu" + create_dir "$XDG_CONFIG_HOME/xemu" + mv -f "$multi_user_data_folder/$single_user/config/xemu"/{.[!.],}* "$XDG_CONFIG_HOME/xemu" + dir_prep "$XDG_CONFIG_HOME/xemu" "$XDG_DATA_HOME/xemu/xemu" create_dir "$saves_folder" create_dir "$states_folder" mv -f "$multi_user_data_folder/$single_user/saves"/{.[!.],}* "$saves_folder" @@ -172,9 +172,9 @@ multi_user_return_to_single_user() { for emu_conf in $(find "$multi_user_data_folder/$single_user/config" -mindepth 1 -maxdepth 1 -type d -printf '%f\n') do if [[ ! -z $(grep "^$emu_conf$" "$multi_user_emulator_config_dirs") ]]; then - unlink "/var/config/$emu_conf" - create_dir "/var/config/$emu_conf" - mv -f "$multi_user_data_folder/$single_user/config/$emu_conf"/{.[!.],}* "/var/config/$emu_conf" + unlink "$XDG_CONFIG_HOME/$emu_conf" + create_dir "$XDG_CONFIG_HOME/$emu_conf" + mv -f "$multi_user_data_folder/$single_user/config/$emu_conf"/{.[!.],}* "$XDG_CONFIG_HOME/$emu_conf" fi done rm -r "$multi_user_data_folder/$single_user" # Should be empty, omitting -f for safety @@ -192,9 +192,9 @@ multi_user_setup_new_user() { rm -f "$rd_conf" ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retrodeck/retrodeck.cfg" "$rd_conf" create_dir "$multi_user_data_folder/$SteamAppUser/config/retroarch" - if [[ ! -L "/var/config/retroarch/retroarch.cfg" ]]; then - mv "/var/config/retroarch/retroarch.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" - mv "/var/config/retroarch/retroarch-core-options.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" + if [[ ! -L "$XDG_CONFIG_HOME/retroarch/retroarch.cfg" ]]; then + mv "$XDG_CONFIG_HOME/retroarch/retroarch.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" + mv "$XDG_CONFIG_HOME/retroarch/retroarch-core-options.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" else cp "$config/retroarch/retroarch.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" cp "$config/retroarch/retroarch-core-options.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" @@ -202,19 +202,19 @@ multi_user_setup_new_user() { set_setting_value "$raconf" "savestate_directory" "$states_folder" "retroarch" set_setting_value "$raconf" "screenshot_directory" "$screenshots_folder" "retroarch" fi - ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" "/var/config/retroarch/retroarch.cfg" - ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" "/var/config/retroarch/retroarch-core-options.cfg" - for emu_conf in $(find "/var/config" -mindepth 1 -maxdepth 1 -type l -printf '%f\n') # For all the config folders already linked to a different user + ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" "$XDG_CONFIG_HOME/retroarch/retroarch.cfg" + ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" "$XDG_CONFIG_HOME/retroarch/retroarch-core-options.cfg" + for emu_conf in $(find "$XDG_CONFIG_HOME" -mindepth 1 -maxdepth 1 -type l -printf '%f\n') # For all the config folders already linked to a different user do if [[ ! -z $(grep "^$emu_conf$" "$multi_user_emulator_config_dirs") ]]; then - unlink "/var/config/$emu_conf" + unlink "$XDG_CONFIG_HOME/$emu_conf" prepare_component "reset" "$emu_conf" fi done - for emu_conf in $(find "/var/config" -mindepth 1 -maxdepth 1 -type d -printf '%f\n') # For all the currently non-linked config folders, like from a newly-added emulator + for emu_conf in $(find "$XDG_CONFIG_HOME" -mindepth 1 -maxdepth 1 -type d -printf '%f\n') # For all the currently non-linked config folders, like from a newly-added emulator do if [[ ! -z $(grep "^$emu_conf$" "$multi_user_emulator_config_dirs") ]]; then - dir_prep "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "/var/config/$emu_conf" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "$XDG_CONFIG_HOME/$emu_conf" fi done } @@ -224,22 +224,22 @@ multi_user_link_current_user_files() { ln -sfT "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder" ln -sfT "$multi_user_data_folder/$SteamAppUser/states" "$states_folder" ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retrodeck/retrodeck.cfg" "$rd_conf" - ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" "/var/config/retroarch/retroarch.cfg" - ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" "/var/config/retroarch/retroarch-core-options.cfg" - for emu_conf in $(find "/var/config" -mindepth 1 -maxdepth 1 -type d -printf '%f\n') # Find any new emulator config folders from last time this user played + ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch.cfg" "$XDG_CONFIG_HOME/retroarch/retroarch.cfg" + ln -sfT "$multi_user_data_folder/$SteamAppUser/config/retroarch/retroarch-core-options.cfg" "$XDG_CONFIG_HOME/retroarch/retroarch-core-options.cfg" + for emu_conf in $(find "$XDG_CONFIG_HOME" -mindepth 1 -maxdepth 1 -type d -printf '%f\n') # Find any new emulator config folders from last time this user played do if [[ ! -z $(grep "^$emu_conf$" "$multi_user_emulator_config_dirs") ]]; then - dir_prep "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "/var/config/$emu_conf" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "$XDG_CONFIG_HOME/$emu_conf" fi done - for emu_conf in $(find "/var/config" -mindepth 1 -maxdepth 1 -type l -printf '%f\n') + for emu_conf in $(find "$XDG_CONFIG_HOME" -mindepth 1 -maxdepth 1 -type l -printf '%f\n') do if [[ ! -z $(grep "^$emu_conf$" "$multi_user_emulator_config_dirs") ]]; then if [[ -d "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" ]]; then # If the current user already has a config folder for this emulator ln -sfT "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "retrodeck/config/$emu_conf" else # If the current user doesn't have a config folder for this emulator, init it and then link it prepare_component "reset" "$emu_conf" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "/var/config/$emu_conf" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/$emu_conf" "$XDG_CONFIG_HOME/$emu_conf" fi fi done diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 0a35a8ad..e455f2ce 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -80,8 +80,8 @@ move() { # Function to move a directory from one parent to another # USAGE: move $source_dir $dest_dir - source_dir="$(echo $1 | sed 's![^/]$!&/!')" # Add trailing slash if it is missing - dest_dir="$(echo $2 | sed 's![^/]$!&/!')" # Add trailing slash if it is missing + source_dir="$(echo "$1" | sed 's![^/]$!&/!')" # Add trailing slash if it is missing + dest_dir="$(echo "$2" | sed 's![^/]$!&/!')" # Add trailing slash if it is missing log d "Moving \"$source_dir\" to \"$dest_dir\"" @@ -147,17 +147,17 @@ update_rd_conf() { # STAGE 1: For current files that haven't been broken into sections yet, where every setting name is unique conf_read # Read current settings into memory - mv -f $rd_conf $rd_conf_backup # Backup config file before update - cp $rd_defaults $rd_conf # Copy defaults file into place + mv -f "$rd_conf" "$rd_conf_backup" # Backup config file before update + cp "$rd_defaults" "$rd_conf" # Copy defaults file into place conf_write # Write old values into new retrodeck.cfg file # STAGE 2: To handle presets sections that use duplicate setting names - generate_single_patch $rd_defaults $rd_conf_backup $rd_update_patch retrodeck # Create a patch file for differences between defaults and current user settings - 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 # Re-apply user settings to defaults file - set_setting_value $rd_conf "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg - rm -f $rd_update_patch # Cleanup temporary patch file + generate_single_patch "$rd_defaults" "$rd_conf_backup" "$rd_update_patch" retrodeck # Create a patch file for differences between defaults and current user settings + 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" # Re-apply user settings to defaults file + set_setting_value "$rd_conf" "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg + rm -f "$rd_update_patch" # Cleanup temporary patch file conf_read # Read all settings into memory # STAGE 3: Create new folders that were added to the shipped retrodeck.cfg, if any @@ -196,13 +196,13 @@ update_rd_conf() { "\(.key):\(.value)", "\(.value):\(.key)" ] | join("\n") - ' $features) + ' "$features") while IFS= read -r current_setting_line # Read the existing retrodeck.cfg do if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$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 - local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name + local current_section=$(sed 's^[][]^^g' <<< "$current_setting_line") # Remove brackets from section name else if [[ ! ("$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" || "$current_section" == "cheevos" || "$current_section" == "cheevos_hardcore") ]]; then local system_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line @@ -220,7 +220,7 @@ update_rd_conf() { fi fi fi - done < $rd_conf + done < "$rd_conf" } conf_read() { @@ -252,7 +252,7 @@ conf_write() { do if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$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 - local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name + local current_section=$(sed 's^[][]^^g' <<< "$current_setting_line") # Remove brackets from section name else if [[ "$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" ]]; then local current_setting_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line @@ -264,7 +264,7 @@ conf_write() { fi fi fi - done < $rd_conf + done < "$rd_conf" log d "retrodeck.cfg written" } @@ -335,7 +335,7 @@ rd_zenity() { unset CONFIGURATOR_GUI - return $status + return "$status" } update_rpcs3_firmware() { @@ -394,7 +394,7 @@ backup_retrodeck_userdata() { local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "paths") config_paths["$current_setting_name"]="$current_setting_value" fi - done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') + done < <(grep -v '^\s*$' "$rd_conf" | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') # Determine which paths to backup if [[ "$backup_type" == "complete" ]]; then @@ -553,7 +553,7 @@ backup_retrodeck_userdata() { path_size=$(du -sk "$path" 2>/dev/null | cut -f1) # Get size in KB path_size=$((path_size * 1024)) # Convert to bytes for calculation total_size=$((total_size + path_size)) - echo "$total_size" > $total_size_file + echo "$total_size" > "$total_size_file" fi done ) | @@ -578,15 +578,15 @@ backup_retrodeck_userdata() { available_space=$(df -B1 "$backups_folder" | awk 'NR==2 {print $4}') # Log sizes for reference - log i "Total size of backup data: $(numfmt --to=iec-i --suffix=B $total_size)" - log i "Available space at destination: $(numfmt --to=iec-i --suffix=B $available_space)" + log i "Total size of backup data: $(numfmt --to=iec-i --suffix=B "$total_size")" + log i "Available space at destination: $(numfmt --to=iec-i --suffix=B "$available_space")" # Check if we have enough space (using uncompressed size as a conservative estimate) if [[ "$available_space" -lt "$total_size" ]]; then if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then - configurator_generic_dialog "RetroDECK Userdata Backup" "There is not enough free space to perform this backup.\n\nYou need at least $(numfmt --to=iec-i --suffix=B $total_size),\nplease free up some space and try again." + configurator_generic_dialog "RetroDECK Userdata Backup" "There is not enough free space to perform this backup.\n\nYou need at least $(numfmt --to=iec-i --suffix=B "$total_size"),\nplease free up some space and try again." fi - log e "Error: Not enough space to perform backup. Need at least $(numfmt --to=iec-i --suffix=B $total_size)" + log e "Error: Not enough space to perform backup. Need at least $(numfmt --to=iec-i --suffix=B "$total_size")" return 1 fi @@ -853,9 +853,9 @@ install_retrodeck_starterpack() { ## DOOM section ## cp /app/retrodeck/extras/doom1.wad "$roms_folder/doom/doom1.wad" # No -f in case the user already has it - create_dir "/var/config/ES-DE/gamelists/doom" - if [[ ! -f "/var/config/ES-DE/gamelists/doom/gamelist.xml" ]]; then # Don't overwrite an existing gamelist - cp "/app/retrodeck/rd_prepacks/doom/gamelist.xml" "/var/config/ES-DE/gamelists/doom/gamelist.xml" + create_dir "$XDG_CONFIG_HOME/ES-DE/gamelists/doom" + if [[ ! -f "$XDG_CONFIG_HOME/ES-DE/gamelists/doom/gamelist.xml" ]]; then # Don't overwrite an existing gamelist + cp "/app/retrodeck/rd_prepacks/doom/gamelist.xml" "$XDG_CONFIG_HOME/ES-DE/gamelists/doom/gamelist.xml" fi create_dir "$media_folder/doom" unzip -oq "/app/retrodeck/rd_prepacks/doom/doom.zip" -d "$media_folder/doom/" @@ -893,8 +893,8 @@ update_splashscreens() { log i "Updating splash screen" - rm -rf /var/config/ES-DE/resources/graphics - rsync -rlD --mkpath "/app/retrodeck/graphics/" "/var/config/ES-DE/resources/graphics/" + rm -rf "$XDG_CONFIG_HOME/ES-DE/resources/graphics" + rsync -rlD --mkpath "/app/retrodeck/graphics/" "$XDG_CONFIG_HOME/ES-DE/resources/graphics/" } @@ -930,7 +930,7 @@ splash_screen() { ($current_day | tonumber) <= (.value.end_date | tonumber) and ($current_time | tonumber) >= (.value.start_time | tonumber) and ($current_time | tonumber) <= (.value.end_time | tonumber) - ) | .value.filename' $features) + ) | .value.filename' "$features") # Determine the splash file to use if [[ -n "$splash_screen" ]]; then @@ -972,7 +972,7 @@ install_release() { mkdir -p "$rdhome/RetroDECK_Updates" # Download the flatpak file - wget -P "$rdhome/RetroDECK_Updates" $flatpak_url -O "$rdhome/RetroDECK_Updates/RetroDECK$iscooker.flatpak" + wget -P "$rdhome/RetroDECK_Updates" "$flatpak_url" -O "$rdhome/RetroDECK_Updates/RetroDECK$iscooker.flatpak" # Check if the download was successful if [[ $? -ne 0 ]]; then @@ -1012,13 +1012,13 @@ ponzu() { local executable # if the binaries are found, ponzu should be set as true into the retrodeck config - if [ -f "/var/data/ponzu/Citra/bin/citra-qt" ]; then + if [ -f "$XDG_DATA_HOME/ponzu/Citra/bin/citra-qt" ]; then log d "Citra binaries has already been installed, checking for updates and forcing the setting as true." - set_setting_value $rd_conf "akai_ponzu" "true" retrodeck "options" + set_setting_value "$rd_conf" "akai_ponzu" "true" retrodeck "options" fi - if [ -f "/var/data/ponzu/Yuzu/bin/yuzu" ]; then + if [ -f "$XDG_DATA_HOME/ponzu/Yuzu/bin/yuzu" ]; then log d "Yuzu binaries has already been installed, checking for updates and forcing the setting as true." - set_setting_value $rd_conf "kiroi_ponzu" "true" retrodeck "options" + set_setting_value "$rd_conf" "kiroi_ponzu" "true" retrodeck "options" fi # Loop through all ponzu files @@ -1027,11 +1027,11 @@ ponzu() { if [ -f "$ponzu_file" ]; then if [[ "$ponzu_file" == *itra* ]]; then log i "Found akai ponzu! Elaborating it" - data_dir="/var/data/ponzu/Citra" + data_dir="$XDG_DATA_HOME/ponzu/Citra" local message="Akai ponzu is served, enjoy" elif [[ "$ponzu_file" == *uzu* ]]; then log i "Found kiroi ponzu! Elaborating it" - data_dir="/var/data/ponzu/Yuzu" + data_dir="$XDG_DATA_HOME/ponzu/Yuzu" local message="Kiroi ponzu is served, enjoy" else log e "AppImage not recognized, not a ponzu ingredient!" @@ -1059,14 +1059,14 @@ ponzu() { chmod +x "$executable" chmod +x "$executable-qt" prepare_component "reset" "citra" - set_setting_value $rd_conf "akai_ponzu" "true" retrodeck "options" + set_setting_value "$rd_conf" "akai_ponzu" "true" retrodeck "options" elif [[ "$ponzu_file" == *uzu* ]]; then mv "$tmp_folder/usr/"** . executable="$data_dir/bin/yuzu" log d "Making $executable executable" chmod +x "$executable" prepare_component "reset" "yuzu" - set_setting_value $rd_conf "kiroi_ponzu" "true" retrodeck "options" + set_setting_value "$rd_conf" "kiroi_ponzu" "true" retrodeck "options" fi cd - @@ -1084,15 +1084,15 @@ ponzu_remove() { if [[ "$1" == "citra" ]]; then if [[ $(configurator_generic_question_dialog "Ponzu - Remove Citra" "Do you really want to remove Citra binaries?\n\nYour games and saves will not be deleted.") == "true" ]]; then log i "Ponzu: removing Citra" - rm -rf "/var/data/ponzu/Citra" - set_setting_value $rd_conf "akai_ponzu" "false" retrodeck "options" + rm -rf "$XDG_DATA_HOME/ponzu/Citra" + set_setting_value "$rd_conf" "akai_ponzu" "false" retrodeck "options" configurator_generic_dialog "Ponzu - Remove Citra" "Done, Citra is now removed from RetroDECK" fi elif [[ "$1" == "yuzu" ]]; then if [[ $(configurator_generic_question_dialog "Ponzu - Remove Yuzu" "Do you really want to remove Yuzu binaries?\n\nYour games and saves will not be deleted.") == "true" ]]; then log i "Ponzu: removing Yuzu" - rm -rf "/var/data/ponzu/Yuzu" - set_setting_value $rd_conf "kiroi_ponzu" "false" retrodeck "options" + rm -rf "$XDG_DATA_HOME/ponzu/Yuzu" + set_setting_value "$rd_conf" "kiroi_ponzu" "false" retrodeck "options" configurator_generic_dialog "Ponzu - Remove Yuzu" "Done, Yuzu is now removed from RetroDECK" fi else @@ -1115,7 +1115,7 @@ release_selector() { # Fetch the main release from the RetroDECK repository log d "Fetching latest main release from GitHub API for repository RetroDECK" - local main_release=$(curl -s https://api.github.com/repos/$git_organization_name/RetroDECK/releases/latest) + local main_release=$(curl -s "https://api.github.com/repos/$git_organization_name/RetroDECK/releases/latest") if [[ -z "$main_release" ]]; then log e "Failed to fetch the main release" @@ -1134,7 +1134,7 @@ release_selector() { local release_array=("Main Release" "$main_tag_name" "$main_human_readable_date") # Fetch all releases (including draft and pre-release) from the Cooker repository - local releases=$(curl -s https://api.github.com/repos/$git_organization_name/$cooker_repository_name/releases?per_page=100) + local releases=$(curl -s "https://api.github.com/repos/$git_organization_name/$cooker_repository_name/releases?per_page=100") if [[ -z "$releases" ]]; then log e "Failed to fetch releases or no releases available" @@ -1220,16 +1220,16 @@ release_selector() { log d "User confirmed installation of release $selected_tag" if echo "$selected_release" | grep -q "Main Release"; then - set_setting_value $rd_conf "update_repo" "$main_repository_name" retrodeck "options" + set_setting_value "$rd_conf" "update_repo" "$main_repository_name" retrodeck "options" log i "Switching to main channel" else - set_setting_value $rd_conf "update_repo" "$cooker_repository_name" retrodeck "options" + set_setting_value "$rd_conf" "update_repo" "$cooker_repository_name" retrodeck "options" log i "Switching to cooker channel" fi set_setting_value "$rd_conf" "branch" "$selected_branch" "retrodeck" "options" log d "Set branch to $selected_branch in configuration" - install_release $selected_tag + install_release "$selected_tag" else log d "User canceled installation" @@ -1294,21 +1294,21 @@ retroarch_updater(){ log i "Running RetroArch updater" # Synchronize cores from the application share directory to the RetroArch cores directory - rsync -rlD --mkpath "/app/share/libretro/cores/" "/var/config/retroarch/cores/" && log d "RetroArch cores updated correctly" + rsync -rlD --mkpath "/app/share/libretro/cores/" "$XDG_CONFIG_HOME/retroarch/cores/" && log d "RetroArch cores updated correctly" # Synchronize border overlays from the RetroDeck configuration directory to the RetroArch overlays directory - rsync -rlD --mkpath "/app/retrodeck/config/retroarch/borders/" "/var/config/retroarch/overlays/borders/" && log d "RetroArch overlays and borders updated correctly" + rsync -rlD --mkpath "/app/retrodeck/config/retroarch/borders/" "$XDG_CONFIG_HOME/retroarch/overlays/borders/" && log d "RetroArch overlays and borders updated correctly" } portmaster_show(){ log d "Setting PortMaster visibility in ES-DE" if [ "$1" = "true" ]; then log d "\"$roms_folder/portmaster/PortMaster.sh\" is not found, installing it" - install -Dm755 "/var/data/PortMaster/PortMaster.sh" "$roms_folder/portmaster/PortMaster.sh" && log d "PortMaster is correctly showing in ES-DE" - set_setting_value $rd_conf "portmaster_show" "true" retrodeck "options" + install -Dm755 "$XDG_DATA_HOME/PortMaster/PortMaster.sh" "$roms_folder/portmaster/PortMaster.sh" && log d "PortMaster is correctly showing in ES-DE" + set_setting_value "$rd_conf" "portmaster_show" "true" retrodeck "options" elif [ "$1" = "false" ]; then rm -rf "$roms_folder/portmaster/PortMaster.sh" && log d "PortMaster is correctly hidden in ES-DE" - set_setting_value $rd_conf "portmaster_show" "false" retrodeck "options" + set_setting_value "$rd_conf" "portmaster_show" "false" retrodeck "options" else log e "\"$1\" is not a valid choice, quitting" fi @@ -1430,7 +1430,7 @@ repair_paths() { fi fi fi - done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') + done < <(grep -v '^\s*$' "$rd_conf" | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') if [[ $invalid_path_found == "true" ]]; then log i "One or more invalid paths repaired, fixing internal RetroDECK structures" diff --git a/functions/post_build_check.sh b/functions/post_build_check.sh index dcecd71f..8720a44b 100755 --- a/functions/post_build_check.sh +++ b/functions/post_build_check.sh @@ -21,7 +21,7 @@ run_and_check() { fi # Run command with timeout - timeout -s TERM $TIMEOUT $full_cmd + timeout -s TERM $TIMEOUT "$full_cmd" local exit_code=$? # Log the results @@ -52,4 +52,4 @@ for entry in "${commands[@]}"; do # Run the command with optional CLI argument run_and_check "$cmd" "$cli_arg" -done \ No newline at end of file +done diff --git a/functions/post_update.sh b/functions/post_update.sh index 152358da..77ce9f89 100644 --- a/functions/post_update.sh +++ b/functions/post_update.sh @@ -40,7 +40,7 @@ post_update() { local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "paths") compressible_paths=("${compressible_paths[@]}" "false" "$current_setting_name" "$current_setting_value") fi - done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') + done < <(grep -v '^\s*$' "$rd_conf" | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') choice=$(rd_zenity \ --list --width=1200 --height=720 \ @@ -92,11 +92,11 @@ post_update() { # - Duckstation save and state locations were dir_prep'd to the rdhome/save and /state folders, which was not previously done. Much safer now! # - Fix PICO-8 folder structure. ROM and save folders are now sane and binary files will go into ~/retrodeck/bios/pico-8/ - rm -rf /var/config/primehack # Purge old Primehack config files. Saves are safe as they are linked into /var/data/primehack. + rm -rf "$XDG_CONFIG_HOME/primehack" # Purge old Primehack config files. Saves are safe as they are linked into $XDG_DATA_HOME/primehack. prepare_component "reset" "primehack" - dir_prep "$rdhome/saves/duckstation" "/var/data/duckstation/memcards" - dir_prep "$rdhome/states/duckstation" "/var/data/duckstation/savestates" + dir_prep "$rdhome/saves/duckstation" "$XDG_DATA_HOME/duckstation/memcards" + dir_prep "$rdhome/states/duckstation" "$XDG_DATA_HOME/duckstation/savestates" mv "$bios_folder/pico8" "$bios_folder/pico8_olddata" # Move legacy (and incorrect / non-functional ) PICO-8 location for future cleanup / less confusion dir_prep "$bios_folder/pico-8" "$HOME/.lexaloffle/pico-8" # Store binary and config files together. The .lexaloffle directory is a hard-coded location for the PICO-8 config file, cannot be changed @@ -109,21 +109,21 @@ post_update() { # - Fix symlink to hard-coded PICO-8 config folder (dir_prep doesn't like ~) # - Overwrite Citra and Yuzu configs, as controller mapping was broken due to emulator updates. - dir_prep "$rdhome/states/dolphin" "/var/data/dolphin-emu/StateSaves" - dir_prep "$rdhome/states/primehack" "/var/data/primehack/StateSaves" + dir_prep "$rdhome/states/dolphin" "$XDG_DATA_HOME/dolphin-emu/StateSaves" + dir_prep "$rdhome/states/primehack" "$XDG_DATA_HOME/primehack/StateSaves" rm -rf "$HOME/~/" # Remove old incorrect location from 0.6.2b rm -f "$HOME/.lexaloffle/pico-8" # Remove old symlink to prevent recursion dir_prep "$bios_folder/pico-8" "$HOME/.lexaloffle/pico-8" # Store binary and config files together. The .lexaloffle directory is a hard-coded location for the PICO-8 config file, cannot be changed dir_prep "$saves_folder/pico-8" "$bios_folder/pico-8/cdata" # PICO-8 saves folder structure was backwards, fixing for consistency. - cp -f "$config/citra/qt-config.ini" /var/config/citra-emu/qt-config.ini - sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' /var/config/citra-emu/qt-config.ini - cp -fr "$config/yuzu/"* /var/config/yuzu/ - sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' /var/config/yuzu/qt-config.ini + cp -f "$config/citra/qt-config.ini" "$XDG_CONFIG_HOME/citra-emu/qt-config.ini" + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$XDG_CONFIG_HOME/citra-emu/qt-config.ini" + cp -fr "$config/yuzu/"* "$XDG_CONFIG_HOME/yuzu/" + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$XDG_CONFIG_HOME/yuzu/qt-config.ini" # Remove unneeded tools folder, as location has changed to RO space - rm -rfv /var/config/retrodeck/tools/ + rm -rfv "$XDG_CONFIG_HOME/retrodeck/tools/" fi if [[ $(check_version_is_older_than "$version_being_updated" "0.6.4b") == "true" ]]; then # In version 0.6.4b, the following changes were made: @@ -137,12 +137,12 @@ post_update() { # In version 0.6.5b, the following changes were made: # Change Yuzu GPU accuracy to normal for better performance - set_setting_value $yuzuconf "gpu_accuracy" "0" "yuzu" "Renderer" + set_setting_value "$yuzuconf" "gpu_accuracy" "0" "yuzu" "Renderer" fi if [[ $(check_version_is_older_than "$version_being_updated" "0.7.0b") == "true" ]]; then # In version 0.7.0b, the following changes were made that required config file updates/reset or other changes to the filesystem: # - Update retrodeck.cfg and set new paths to $rdhome by default - # - Update PCSX2 and Duckstation configs to latest templates (to accomadate RetroAchievements feature) and move Duckstation config folder from /var/data to /var/config + # - Update PCSX2 and Duckstation configs to latest templates (to accomadate RetroAchievements feature) and move Duckstation config folder from $XDG_DATA_HOME to $XDG_CONFIG_HOME # - New ~/retrodeck/mods and ~/retrodeck/texture_packs directories are added and symlinked to multiple different emulators (where supported) # - Expose ES-DE gamelists folder to user at ~/retrodeck/gamelists # - Copy new borders into RA config location @@ -162,52 +162,52 @@ post_update() { # - Init PICO-8 as it has newly-shipped config files update_rd_conf # Expand retrodeck.cfg to latest template - set_setting_value $rd_conf "screenshots_folder" "$rdhome/screenshots" - set_setting_value $rd_conf "mods_folder" "$rdhome/mods" - set_setting_value $rd_conf "texture_packs_folder" "$rdhome/texture_packs" - set_setting_value $rd_conf "borders_folder" "$rdhome/borders" + set_setting_value "$rd_conf" "screenshots_folder" "$rdhome/screenshots" + set_setting_value "$rd_conf" "mods_folder" "$rdhome/mods" + set_setting_value "$rd_conf" "texture_packs_folder" "$rdhome/texture_packs" + set_setting_value "$rd_conf" "borders_folder" "$rdhome/borders" conf_read mv -f "$pcsx2conf" "$pcsx2conf.bak" - generate_single_patch "$config/PCSX2/PCSX2.ini" "$pcsx2conf.bak" "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch" pcsx2 - deploy_single_patch "$config/PCSX2/PCSX2.ini" "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch" "$pcsx2conf" - rm -f "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch" - dir_prep "/var/config/duckstation" "/var/data/duckstation" + generate_single_patch "$config/PCSX2/PCSX2.ini" "$pcsx2conf.bak" "$XDG_CONFIG_HOME/PCSX2/inis/PCSX2-cheevos-upgrade.patch" pcsx2 + deploy_single_patch "$config/PCSX2/PCSX2.ini" "$XDG_CONFIG_HOME/PCSX2/inis/PCSX2-cheevos-upgrade.patch" "$pcsx2conf" + rm -f "$XDG_CONFIG_HOME/PCSX2/inis/PCSX2-cheevos-upgrade.patch" + dir_prep "$XDG_CONFIG_HOME/duckstation" "$XDG_DATA_HOME/duckstation" mv -f "$duckstationconf" "$duckstationconf.bak" - generate_single_patch "$config/duckstation/settings.ini" "$duckstationconf.bak" "/var/config/duckstation/duckstation-cheevos-upgrade.patch" pcsx2 - deploy_single_patch "$config/duckstation/settings.ini" "/var/config/duckstation/duckstation-cheevos-upgrade.patch" "$duckstationconf" - rm -f "/var/config/duckstation/duckstation-cheevos-upgrade.patch" + generate_single_patch "$config/duckstation/settings.ini" "$duckstationconf.bak" "$XDG_CONFIG_HOME/duckstation/duckstation-cheevos-upgrade.patch" pcsx2 + deploy_single_patch "$config/duckstation/settings.ini" "$XDG_CONFIG_HOME/duckstation/duckstation-cheevos-upgrade.patch" "$duckstationconf" + rm -f "$XDG_CONFIG_HOME/duckstation/duckstation-cheevos-upgrade.patch" create_dir "$mods_folder" create_dir "$texture_packs_folder" create_dir "$borders_folder" - dir_prep "$mods_folder/Primehack" "/var/data/primehack/Load/GraphicMods" - dir_prep "$texture_packs_folder/Primehack" "/var/data/primehack/Load/Textures" - dir_prep "$mods_folder/Dolphin" "/var/data/dolphin-emu/Load/GraphicMods" - dir_prep "$texture_packs_folder/Dolphin" "/var/data/dolphin-emu/Load/Textures" - dir_prep "$mods_folder/Citra" "/var/data/citra-emu/load/mods" - dir_prep "$texture_packs_folder/Citra" "/var/data/citra-emu/load/textures" - dir_prep "$mods_folder/Yuzu" "/var/data/yuzu/load" - dir_prep "$texture_packs_folder/RetroArch-Mesen" "/var/config/retroarch/system/HdPacks" - dir_prep "$texture_packs_folder/PPSSPP" "/var/config/ppsspp/PSP/TEXTURES" - dir_prep "$texture_packs_folder/PCSX2" "/var/config/PCSX2/textures" - dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/cache" "/var/config/retroarch/system/Mupen64plus/cache" - dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" "/var/config/retroarch/system/Mupen64plus/hires_texture" - dir_prep "$texture_packs_folder/Duckstation" "/var/config/duckstation/textures" + dir_prep "$mods_folder/Primehack" "$XDG_DATA_HOME/primehack/Load/GraphicMods" + dir_prep "$texture_packs_folder/Primehack" "$XDG_DATA_HOME/primehack/Load/Textures" + dir_prep "$mods_folder/Dolphin" "$XDG_DATA_HOME/dolphin-emu/Load/GraphicMods" + dir_prep "$texture_packs_folder/Dolphin" "$XDG_DATA_HOME/dolphin-emu/Load/Textures" + dir_prep "$mods_folder/Citra" "$XDG_DATA_HOME/citra-emu/load/mods" + dir_prep "$texture_packs_folder/Citra" "$XDG_DATA_HOME/citra-emu/load/textures" + dir_prep "$mods_folder/Yuzu" "$XDG_DATA_HOME/yuzu/load" + dir_prep "$texture_packs_folder/RetroArch-Mesen" "$XDG_CONFIG_HOME/retroarch/system/HdPacks" + dir_prep "$texture_packs_folder/PPSSPP" "$XDG_CONFIG_HOME/ppsspp/PSP/TEXTURES" + dir_prep "$texture_packs_folder/PCSX2" "$XDG_CONFIG_HOME/PCSX2/textures" + dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/cache" "$XDG_CONFIG_HOME/retroarch/system/Mupen64plus/cache" + dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" "$XDG_CONFIG_HOME/retroarch/system/Mupen64plus/hires_texture" + dir_prep "$texture_packs_folder/Duckstation" "$XDG_CONFIG_HOME/duckstation/textures" - dir_prep "$rdhome/gamelists" "/var/config/emulationstation/ES-DE/gamelists" + dir_prep "$rdhome/gamelists" "$XDG_CONFIG_HOME/emulationstation/ES-DE/gamelists" - dir_prep "$borders_folder" "/var/config/retroarch/overlays/borders" - rsync -rlD --mkpath "/app/retrodeck/config/retroarch/borders/" "/var/config/retroarch/overlays/borders/" + dir_prep "$borders_folder" "$XDG_CONFIG_HOME/retroarch/overlays/borders" + rsync -rlD --mkpath "/app/retrodeck/config/retroarch/borders/" "$XDG_CONFIG_HOME/retroarch/overlays/borders/" - rsync -rlD --mkpath "$config/retrodeck/presets/remaps/" "/var/config/retroarch/config/remaps/" + rsync -rlD --mkpath "$config/retrodeck/presets/remaps/" "$XDG_CONFIG_HOME/retroarch/config/remaps/" if [[ ! -f "$bios_folder/capsimg.so" ]]; then cp -f "/app/retrodeck/extras/Amiga/capsimg.so" "$bios_folder/capsimg.so" fi - cp -f $config/rpcs3/vfs.yml /var/config/rpcs3/vfs.yml + cp -f "$config/rpcs3/vfs.yml" "$XDG_CONFIG_HOME/rpcs3/vfs.yml" sed -i 's^\^$(EmulatorDir): .*^$(EmulatorDir): '"$bios_folder/rpcs3/"'^' "$rpcs3vfsconf" set_setting_value "$rpcs3vfsconf" "/games/" "$roms_folder/ps3/" "rpcs3" if [[ -d "$roms_folder/ps3/emudir" ]]; then # The old location exists, meaning the emulator was run at least once. @@ -225,7 +225,7 @@ post_update() { create_dir "$bios_folder/rpcs3/dev_usb000" dir_prep "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata" "$saves_folder/ps3/rpcs3" - set_setting_value $es_settings "ApplicationUpdaterFrequency" "never" "es_settings" + set_setting_value "$es_settings" "ApplicationUpdaterFrequency" "never" "es_settings" if [[ -f "$saves_folder/duckstation/shared_card_1.mcd" || -f "$saves_folder/duckstation/shared_card_2.mcd" ]]; then configurator_generic_dialog "RetroDECK 0.7.0b Upgrade" "As part of this update, the location of saves and states for Duckstation has been changed.\n\nYour files will be moved automatically, and can now be found at\n\n~.../saves/psx/duckstation/memcards/\nand\n~.../states/psx/duckstation/" @@ -233,42 +233,42 @@ post_update() { create_dir "$saves_folder/psx/duckstation/memcards" mv "$saves_folder/duckstation/"* "$saves_folder/psx/duckstation/memcards/" rmdir "$saves_folder/duckstation" # File-safe folder cleanup - unlink "/var/config/duckstation/memcards" + unlink "$XDG_CONFIG_HOME/duckstation/memcards" set_setting_value "$duckstationconf" "Card1Path" "$saves_folder/psx/duckstation/memcards/shared_card_1.mcd" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "Card2Path" "$saves_folder/psx/duckstation/memcards/shared_card_2.mcd" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "Directory" "$saves_folder/psx/duckstation/memcards" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList" create_dir "$states_folder/psx" mv -t "$states_folder/psx/" "$states_folder/duckstation" - unlink "/var/config/duckstation/savestates" - dir_prep "$states_folder/psx/duckstation" "/var/config/duckstation/savestates" + unlink "$XDG_CONFIG_HOME/duckstation/savestates" + dir_prep "$states_folder/psx/duckstation" "$XDG_CONFIG_HOME/duckstation/savestates" - rm -rf /var/config/retrodeck/tools - rm -rf /var/config/emulationstation/ES-DE/gamelists/tools/ + rm -rf "$XDG_CONFIG_HOME/retrodeck/tools" + rm -rf "$XDG_CONFIG_HOME/emulationstation/ES-DE/gamelists/tools/" mv "$saves_folder/gc/dolphin/EUR" "$saves_folder/gc/dolphin/EU" mv "$saves_folder/gc/dolphin/USA" "$saves_folder/gc/dolphin/US" mv "$saves_folder/gc/dolphin/JAP" "$saves_folder/gc/dolphin/JP" - dir_prep "$saves_folder/gc/dolphin/EU" "/var/data/dolphin-emu/GC/EUR" - dir_prep "$saves_folder/gc/dolphin/US" "/var/data/dolphin-emu/GC/USA" - dir_prep "$saves_folder/gc/dolphin/JP" "/var/data/dolphin-emu/GC/JAP" + dir_prep "$saves_folder/gc/dolphin/EU" "$XDG_DATA_HOME/dolphin-emu/GC/EUR" + dir_prep "$saves_folder/gc/dolphin/US" "$XDG_DATA_HOME/dolphin-emu/GC/USA" + dir_prep "$saves_folder/gc/dolphin/JP" "$XDG_DATA_HOME/dolphin-emu/GC/JAP" mv "$saves_folder/gc/primehack/EUR" "$saves_folder/gc/primehack/EU" mv "$saves_folder/gc/primehack/USA" "$saves_folder/gc/primehack/US" mv "$saves_folder/gc/primehack/JAP" "$saves_folder/gc/primehack/JP" - dir_prep "$saves_folder/gc/primehack/EU" "/var/data/primehack/GC/EUR" - dir_prep "$saves_folder/gc/primehack/US" "/var/data/primehack/GC/USA" - dir_prep "$saves_folder/gc/primehack/JP" "/var/data/primehack/GC/JAP" + dir_prep "$saves_folder/gc/primehack/EU" "$XDG_DATA_HOME/primehack/GC/EUR" + dir_prep "$saves_folder/gc/primehack/US" "$XDG_DATA_HOME/primehack/GC/USA" + dir_prep "$saves_folder/gc/primehack/JP" "$XDG_DATA_HOME/primehack/GC/JAP" - dir_prep "$saves_folder/PSP/PPSSPP-SA" "/var/config/ppsspp/PSP/SAVEDATA" - dir_prep "$states_folder/PSP/PPSSPP-SA" "/var/config/ppsspp/PSP/PPSSPP_STATE" + dir_prep "$saves_folder/PSP/PPSSPP-SA" "$XDG_CONFIG_HOME/ppsspp/PSP/SAVEDATA" + dir_prep "$states_folder/PSP/PPSSPP-SA" "$XDG_CONFIG_HOME/ppsspp/PSP/PPSSPP_STATE" set_setting_value "$es_settings" "ROMDirectory" "$roms_folder" "es_settings" set_setting_value "$es_settings" "MediaDirectory" "$media_folder" "es_settings" sed -i '$ a ' "$es_settings" # Add new default line to existing file set_setting_value "$es_settings" "UserThemeDirectory" "$themes_folder" "es_settings" - unlink "/var/config/emulationstation/ROMs" - unlink "/var/config/emulationstation/ES-DE/downloaded_media" - unlink "/var/config/emulationstation/ES-DE/themes" + unlink "$XDG_CONFIG_HOME/emulationstation/ROMs" + unlink "$XDG_CONFIG_HOME/emulationstation/ES-DE/downloaded_media" + unlink "$XDG_CONFIG_HOME/emulationstation/ES-DE/themes" set_setting_value "$raconf" "savestate_auto_load" "false" "retroarch" set_setting_value "$raconf" "savestate_auto_save" "false" "retroarch" @@ -303,7 +303,7 @@ post_update() { if [[ $(check_version_is_older_than "$version_being_updated" "0.7.3b") == "true" ]]; then # In version 0.7.3b, there was a bug that prevented the correct creations of the roms/system folders, so we force recreate them. - emulationstation --home /var/config/emulationstation --create-system-dirs + emulationstation --home "$XDG_CONFIG_HOME/emulationstation" --create-system-dirs fi if [[ $(check_version_is_older_than "$version_being_updated" "0.8.0b") == "true" ]]; then @@ -342,8 +342,8 @@ post_update() { set_setting_value "$raconf" "rewind_enable" "false" "retroarch" # in 3.0 .emulationstation was moved into ES-DE - log i "Renaming old \"/var/config/emulationstation\" folder as \"/var/config/ES-DE\"" - mv -f /var/config/emulationstation /var/config/ES-DE + log i "Renaming old \"$XDG_CONFIG_HOME/emulationstation\" folder as \"$XDG_CONFIG_HOME/ES-DE\"" + mv -f "$XDG_CONFIG_HOME/emulationstation" "$XDG_CONFIG_HOME/ES-DE" prepare_component "reset" "es-de" prepare_component "reset" "mame" @@ -357,7 +357,7 @@ post_update() { # The save folder of rpcs3 was inverted so we're moving the saves into the real one log i "RPCS3 saves needs to be migrated, executing." - if [[ "$(ls -A $bios_folder/rpcs3/dev_hdd0/home/00000001/savedata)" ]]; then + if [[ "$(ls -A "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata")" ]]; then log i "Existing RPCS3 savedata found, backing up..." create_dir "$backups_folder" zip -rq9 "$backups_folder/$(date +"%0m%0d")_rpcs3_save_data.zip" "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata" @@ -369,7 +369,7 @@ post_update() { mv "$bios_folder/switch/registered" "$bios_folder/switch/firmware" log i "New systems were added in this version, regenerating system folders." - #es-de --home "/var/config/" --create-system-dirs + #es-de --home "$XDG_CONFIG_HOME/" --create-system-dirs es-de --create-system-dirs fi # end of 0.8.0b @@ -380,8 +380,8 @@ post_update() { log i "- Give the user the option to reset Ryujinx, which was not properly initialized in 0.8.0b" log d "ES-DE files were moved inside the retrodeck folder, migrating to the new structure" - dir_prep "$rdhome/ES-DE/collections" "/var/config/ES-DE/collections" - dir_prep "$rdhome/ES-DE/gamelists" "/var/config/ES-DE/gamelists" + dir_prep "$rdhome/ES-DE/collections" "$XDG_CONFIG_HOME/ES-DE/collections" + dir_prep "$rdhome/ES-DE/gamelists" "$XDG_CONFIG_HOME/ES-DE/gamelists" log i "Moving ES-DE collections, downloaded_media, gamelist, and themes from \"$rdhome\" to \"$rdhome/ES-DE\"" set_setting_value "$es_settings" "MediaDirectory" "$rdhome/ES-DE/downloaded_media" "es_settings" set_setting_value "$es_settings" "UserThemeDirectory" "$rdhome/ES-DE/themes" "es_settings" @@ -389,21 +389,21 @@ post_update() { mv -f "$rdhome/downloaded_media" "$rdhome/ES-DE/downloaded_media" && log d "Move of \"$rdhome/downloaded_media\" in \"$rdhome/ES-DE\" folder completed" mv -f "$rdhome/gamelists/"* "$rdhome/ES-DE/gamelists" && log d "Move of \"$rdhome/gamelists/\" in \"$rdhome/ES-DE\" folder completed" && rm -rf "$rdhome/gamelists" - log i "MAME-SA, migrating samples to the new exposed folder: from \"/var/data/mame/assets/samples\" to \"$bios_folder/mame-sa/samples\"" + log i "MAME-SA, migrating samples to the new exposed folder: from \"$XDG_DATA_HOME/mame/assets/samples\" to \"$bios_folder/mame-sa/samples\"" create_dir "$bios_folder/mame-sa/samples" - mv -f "/var/data/mame/assets/samples/"* "$bios_folder/mame-sa/samples" + mv -f "$XDG_DATA_HOME/mame/assets/samples/"* "$bios_folder/mame-sa/samples" set_setting_value "$mameconf" "samplepath" "$bios_folder/mame-sa/samples" "mame" log i "Installing the missing ScummVM assets and renaming \"$mods_folder/RetroArch/ScummVM/themes\" into \"theme\"" mv -f "$mods_folder/RetroArch/ScummVM/themes" "$mods_folder/RetroArch/ScummVM/theme" unzip -o "$config/retroarch/ScummVM.zip" 'scummvm/extra/*' -d /tmp unzip -o "$config/retroarch/ScummVM.zip" 'scummvm/theme/*' -d /tmp - mv -f /tmp/scummvm/extra "$mods_folder/RetroArch/ScummVM" - mv -f /tmp/scummvm/theme "$mods_folder/RetroArch/ScummVM" - rm -rf /tmp/extra /tmp/theme + mv -f "/tmp/scummvm/extra" "$mods_folder/RetroArch/ScummVM" + mv -f "/tmp/scummvm/theme" "$mods_folder/RetroArch/ScummVM" + rm -rf "/tmp/extra /tmp/theme" - log i "Placing cheats in \"/var/data/mame/cheat\"" - unzip -j -o "$config/mame/cheat0264.zip" 'cheat.7z' -d "/var/data/mame/cheat" + log i "Placing cheats in \"$XDG_DATA_HOME/mame/cheat\"" + unzip -j -o "$config/mame/cheat0264.zip" 'cheat.7z' -d "$XDG_DATA_HOME/mame/cheat" log d "Verifying with user if they want to reset Ryujinx" if [[ "$(configurator_generic_question_dialog "RetroDECK 0.8.1b Ryujinx Reset" "In RetroDECK 0.8.0b the Ryujinx emulator was not properly initialized for upgrading users.\nThis would cause Ryujinx to not work properly.\n\nWould you like to reset Ryujinx to default RetroDECK settings now?\n\nIf you have made your own changes to the Ryujinx config, you can decline this reset.")" == "true" ]]; then @@ -413,15 +413,15 @@ post_update() { fi # end of 0.8.1b if [[ $(check_version_is_older_than "$version_being_updated" "0.8.2b") == "true" ]]; then - log i "Vita3K changed some paths, reflecting them: moving \"/var/data/Vita3K\" in \"/var/config/Vita3K\"" - move "/var/data/Vita3K" "/var/config/Vita3K" + log i "Vita3K changed some paths, reflecting them: moving \"$XDG_DATA_HOME/Vita3K\" in \"$XDG_CONFIG_HOME/Vita3K\"" + move "$XDG_DATA_HOME/Vita3K" "$XDG_CONFIG_HOME/Vita3K" log i "Moving ES-DE downloaded_media, gamelist, and themes from \"$rdhome\" to \"$rdhome/ES-DE\" due to a RetroDECK Framework bug" move "$rdhome/themes" "$rdhome/ES-DE/themes" && log d "Move of \"$rdhome/themes\" in \"$rdhome/ES-DE\" folder completed" move "$rdhome/downloaded_media" "$rdhome/ES-DE/downloaded_media" && log d "Move of \"$rdhome/downloaded_media\" in \"$rdhome/ES-DE\" folder completed" move "$rdhome/gamelists" "$rdhome/ES-DE/gamelists" && log d "Move of \"$rdhome/gamelists/\" in \"$rdhome/ES-DE\" folder completed" move "$rdhome/collections" "$rdhome/ES-DE/collections" && log d "Move of \"$rdhome/collections/\" in \"$rdhome/ES-DE\" folder completed" log i "Since in this version we moved to a PR build of Ryujinx we need to symlink it." - ln -sv $ryujinxconf "$(dirname $ryujinxconf)/PRConfig.json" + ln -sv "$ryujinxconf" "$(dirname "$ryujinxconf")/PRConfig.json" fi #end of 0.8.2b if [[ $(check_version_is_older_than "$version_being_updated" "0.8.3b") == "true" ]]; then @@ -605,26 +605,26 @@ post_update() { # RetroArch log i "Forcing RetroArch to use the new libretro info path" - set_setting_value "$raconf" "libretro_info_path" "/var/config/retroarch/cores" "retroarch" + set_setting_value "$raconf" "libretro_info_path" "$XDG_CONFIG_HOME/retroarch/cores" "retroarch" log i "Moving Ryujinx data to the new locations" - if [[ -d "/var/config/Ryujinx/bis" ]]; then - mv -f "/var/config/Ryujinx/bis"/* "$saves_folder/switch/ryujinx/nand" && rm -rf "/var/config/Ryujinx/bis" && log i "Migrated Ryujinx nand data to the new location" + if [[ -d "$XDG_CONFIG_HOME/Ryujinx/bis" ]]; then + mv -f "$XDG_CONFIG_HOME/Ryujinx/bis"/* "$saves_folder/switch/ryujinx/nand" && rm -rf "$XDG_CONFIG_HOME/Ryujinx/bis" && log i "Migrated Ryujinx nand data to the new location" fi - if [[ -d "/var/config/Ryujinx/sdcard" ]]; then - mv -f "/var/config/Ryujinx/sdcard"/* "$saves_folder/switch/ryujinx/sdcard" && rm -rf "/var/config/Ryujinx/sdcard" && log i "Migrated Ryujinx sdcard data to the new location" + if [[ -d "$XDG_CONFIG_HOME/Ryujinx/sdcard" ]]; then + mv -f "$XDG_CONFIG_HOME/Ryujinx/sdcard"/* "$saves_folder/switch/ryujinx/sdcard" && rm -rf "$XDG_CONFIG_HOME/Ryujinx/sdcard" && log i "Migrated Ryujinx sdcard data to the new location" fi - if [[ -d "/var/config/Ryujinx/bis/system/Contents/registered" ]]; then - mv -f "/var/config/Ryujinx/bis/system/Contents/registered"/* "$bios_folder/switch/firmware" && rm -rf "/var/config/Ryujinx/bis/system/Contents/registered" && log i "Migration of Ryujinx firmware data to the new location" + if [[ -d "$XDG_CONFIG_HOME/Ryujinx/bis/system/Contents/registered" ]]; then + mv -f "$XDG_CONFIG_HOME/Ryujinx/bis/system/Contents/registered"/* "$bios_folder/switch/firmware" && rm -rf "$XDG_CONFIG_HOME/Ryujinx/bis/system/Contents/registered" && log i "Migration of Ryujinx firmware data to the new location" fi - if [[ -d "/var/config/Ryujinx/system" ]]; then - mv -f "/var/config/Ryujinx/system"/* "$bios_folder/switch/keys" && rm -rf "/var/config/Ryujinx/system" && log i "Migrated Ryujinx keys data to the new location" + if [[ -d "$XDG_CONFIG_HOME/Ryujinx/system" ]]; then + mv -f "$XDG_CONFIG_HOME/Ryujinx/system"/* "$bios_folder/switch/keys" && rm -rf "$XDG_CONFIG_HOME/Ryujinx/system" && log i "Migrated Ryujinx keys data to the new location" fi - if [[ -d "/var/config/Ryujinx/mods" ]]; then - mv -f "/var/config/Ryujinx/mods"/* "$mods_folder/ryujinx" && rm -rf "/var/config/Ryujinx/mods" && log i "Migrated Ryujinx mods data to the new location" + if [[ -d "$XDG_CONFIG_HOME/Ryujinx/mods" ]]; then + mv -f "$XDG_CONFIG_HOME/Ryujinx/mods"/* "$mods_folder/ryujinx" && rm -rf "$XDG_CONFIG_HOME/Ryujinx/mods" && log i "Migrated Ryujinx mods data to the new location" fi - if [[ -d "/var/config/Ryujinx/screenshots" ]]; then - mv -f "/var/config/Ryujinx/screenshots"/* "$screenshots_folder/ryujinx" && rm -rf "/var/config/Ryujinx/screenshots" && log i "Migrated Ryujinx screenshots to the new location" + if [[ -d "$XDG_CONFIG_HOME/Ryujinx/screenshots" ]]; then + mv -f "$XDG_CONFIG_HOME/Ryujinx/screenshots"/* "$screenshots_folder/ryujinx" && rm -rf "$XDG_CONFIG_HOME/Ryujinx/screenshots" && log i "Migrated Ryujinx screenshots to the new location" fi fi # end of 0.9.0b @@ -708,7 +708,7 @@ post_update() { # --- ALWAYS EXECUTED IN 0.9.1b --- log i "Preparing the shaders folder for MAME..." - shaders_folder=$rdhome/shaders && log i "Shaders folder set to \"$shaders_folder\"" + shaders_folder="$rdhome/shaders" && log i "Shaders folder set to \"$shaders_folder\"" conf_write && log i "Done" create_dir "$shaders_folder/mame/bgfx" set_setting_value "$mameconf" "bgfx_path" "$shaders_folder/mame/bgfx/" "mame" @@ -717,26 +717,26 @@ post_update() { log i "Preparing the cheats for RetroArch..." create_dir "$cheats_folder/retroarch" set_setting_value "$raconf" "cheat_database_path" "$cheats_folder/retroarch" "retroarch" - tar --strip-components=1 -xzf /app/retrodeck/cheats/retroarch.tar.gz -C "$cheats_folder/retroarch" --overwrite && log i "Cheats for RetroArch installed" + tar --strip-components=1 -xzf "/app/retrodeck/cheats/retroarch.tar.gz" -C "$cheats_folder/retroarch" --overwrite && log i "Cheats for RetroArch installed" log i "Preparing the cheats for PPSSPP..." create_dir -d "$cheats_folder/PPSSPP" - dir_prep "$cheats_folder/PPSSPP" "/var/config/ppsspp/PSP/Cheats" - tar -xzf /app/retrodeck/cheats/ppsspp.tar.gz -C "$cheats_folder/PPSSPP" --overwrite && log i "Cheats for PPSSPP installed" + dir_prep "$cheats_folder/PPSSPP" "$XDG_CONFIG_HOME/ppsspp/PSP/Cheats" + tar -xzf "/app/retrodeck/cheats/ppsspp.tar.gz" -C "$cheats_folder/PPSSPP" --overwrite && log i "Cheats for PPSSPP installed" log i "Preparing the cheats for PCSX2..." create_dir "$cheats_folder/pcsx2" set_setting_value "$pcsx2conf" "Cheats" "$cheats_folder/pcsx2" "Folders" - tar --strip-components=1 -xzf /app/retrodeck/cheats/pcsx2.tar.gz -C "$cheats_folder/pcsx2" --overwrite && log i "Cheats for PCSX2 installed" + tar --strip-components=1 -xzf "/app/retrodeck/cheats/pcsx2.tar.gz" -C "$cheats_folder/pcsx2" --overwrite && log i "Cheats for PCSX2 installed" log i "Preparing the cheats for MAME..." create_dir "$cheats_folder/mame" set_setting_value "$mameconf" "cheatpath" "$cheats_folder/mame" "mame" unzip -j -o "$config/mame/cheat0264.zip" 'cheat.7z' -d "$cheats_folder/mame" && log i "Cheats for MAME installed" - rm -rf /var/data/mame/cheat + rm -rf "$XDG_DATA_HOME/mame/cheat" log i "Preparing the RetroAchievements for Dolphin..." - cp -vn "$config/dolphin/"* /var/config/dolphin-emu/ + cp -vn "$config/dolphin/"* "$XDG_CONFIG_HOME/dolphin-emu/" log i "Fixing PrimeHack roms paths..." set_setting_value "$rd_conf" "ppsspp" "$(get_setting_value "$rd_defaults" "ppsspp" "retrodeck" "cheevos")" "retrodeck" "cheevos" @@ -766,18 +766,17 @@ post_update() { fi fi fi - fi # end of 0.9.2b # The following commands are run every time. - if [[ -d "/var/data/dolphin-emu/Load/DynamicInputTextures" ]]; then # Refresh installed textures if they have been enabled + if [[ -d "$XDG_DATA_HOME/dolphin-emu/Load/DynamicInputTextures" ]]; then # Refresh installed textures if they have been enabled log i "Refreshing installed textures for Dolphin..." - rsync -rlD --mkpath "/app/retrodeck/extras/DynamicInputTextures/" "/var/data/dolphin-emu/Load/DynamicInputTextures/" && log i "Done" + rsync -rlD --mkpath "/app/retrodeck/extras/DynamicInputTextures/" "$XDG_DATA_HOME/dolphin-emu/Load/DynamicInputTextures/" && log i "Done" fi - if [[ -d "/var/data/primehack/Load/DynamicInputTextures" ]]; then # Refresh installed textures if they have been enabled + if [[ -d "$XDG_DATA_HOME/primehack/Load/DynamicInputTextures" ]]; then # Refresh installed textures if they have been enabled log i "Refreshing installed textures for Dolphin..." - rsync -rlD --mkpath "/app/retrodeck/extras/DynamicInputTextures/" "/var/data/primehack/Load/DynamicInputTextures/" && log i "Done" + rsync -rlD --mkpath "/app/retrodeck/extras/DynamicInputTextures/" "$XDG_DATA_HOME/primehack/Load/DynamicInputTextures/" && log i "Done" fi if [[ ! -z $(find "$HOME/.steam/steam/controller_base/templates/" -maxdepth 1 -type f -iname "RetroDECK*.vdf") || ! -z $(find "$HOME/.var/app/com.valvesoftware.Steam/.steam/steam/controller_base/templates/" -maxdepth 1 -type f -iname "RetroDECK*.vdf") ]]; then # If RetroDECK controller profile has been previously installed @@ -796,11 +795,11 @@ post_update() { --text="RetroDECK is finishing up the upgrading process, please be patient.\n\nNOTICE - If the process is taking too long:\n\nSome windows might be running in the background that could require your attention: pop-ups from emulators or the upgrade itself that needs user input to continue.\n\n" conf_read - version=$hard_version + version="$hard_version" conf_write - if grep -qF "cooker" <<< $hard_version; then - changelog_dialog "$(echo $version | cut -d'-' -f2)" + if grep -qF "cooker" <<< "$hard_version"; then + changelog_dialog "$(echo "$version" | cut -d'-' -f2)" else changelog_dialog "$version" fi diff --git a/functions/prepare_component.sh b/functions/prepare_component.sh index ad2b2efd..39e8d8a3 100644 --- a/functions/prepare_component.sh +++ b/functions/prepare_component.sh @@ -5,7 +5,7 @@ prepare_component() { # The actions currently include "reset" and "postmove" # The "reset" action will initialize the component # The "postmove" action will update the component settings after one or more RetroDECK folders were moved - # An component can be called by name, by parent folder name in the /var/config root or use the option "all" to perform the action on all components equally + # An component can be called by name, by parent folder name in the $XDG_CONFIG_HOME root or use the option "all" to perform the action on all components equally # USAGE: prepare_component "$action" "$component" "$call_source(optional)" if [[ "$1" == "--list" ]]; then @@ -76,8 +76,8 @@ prepare_component() { log d "Logs folder moved to $logs_folder and linked back to $rd_logs_folder" fi fi - done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') - create_dir "/var/config/retrodeck/godot" # TODO: what is this for? Can we delete it or add it to the retrodeck.cfg so the folder will be created by the above script? + done < <(grep -v '^\s*$' "$rd_conf" | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') + create_dir "$XDG_CONFIG_HOME/retrodeck/godot" # TODO: what is this for? Can we delete it or add it to the retrodeck.cfg so the folder will be created by the above script? fi if [[ "$action" == "postmove" ]]; then # Update the paths of any folders that came with the retrodeck folder during a move @@ -89,7 +89,7 @@ prepare_component() { declare -g "$current_setting_name=$rdhome/${current_setting_value#*retrodeck/}" fi fi - done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') + done < <(grep -v '^\s*$' "$rd_conf" | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f') dir_prep "$logs_folder" "$rd_logs_folder" fi fi @@ -100,16 +100,16 @@ prepare_component() { log i "Prepearing ES-DE" log i "--------------------------------" if [[ "$action" == "reset" ]]; then - rm -rf /var/config/ES-DE - create_dir /var/config/ES-DE/settings + rm -rf "$XDG_CONFIG_HOME/ES-DE" + create_dir "$XDG_CONFIG_HOME/ES-DE/settings" log d "Prepearing es_settings.xml" - cp -f /app/retrodeck/es_settings.xml /var/config/ES-DE/settings/es_settings.xml + cp -f "/app/retrodeck/es_settings.xml" "$XDG_CONFIG_HOME/ES-DE/settings/es_settings.xml" set_setting_value "$es_settings" "ROMDirectory" "$roms_folder" "es_settings" set_setting_value "$es_settings" "MediaDirectory" "$media_folder" "es_settings" set_setting_value "$es_settings" "UserThemeDirectory" "$themes_folder" "es_settings" - dir_prep "$rdhome/ES-DE/gamelists" "/var/config/ES-DE/gamelists" - dir_prep "$rdhome/ES-DE/collections" "/var/config/ES-DE/collections" - dir_prep "$rdhome/ES-DE/custom_systems" "/var/config/ES-DE/custom_systems" + dir_prep "$rdhome/ES-DE/gamelists" "$XDG_CONFIG_HOME/ES-DE/gamelists" + dir_prep "$rdhome/ES-DE/collections" "$XDG_CONFIG_HOME/ES-DE/collections" + dir_prep "$rdhome/ES-DE/custom_systems" "$XDG_CONFIG_HOME/ES-DE/custom_systems" log d "Generating roms system folders" es-de --create-system-dirs update_splashscreens @@ -118,7 +118,7 @@ prepare_component() { set_setting_value "$es_settings" "ROMDirectory" "$roms_folder" "es_settings" set_setting_value "$es_settings" "MediaDirectory" "$media_folder" "es_settings" set_setting_value "$es_settings" "UserThemeDirectory" "$themes_folder" "es_settings" - dir_prep "$rdhome/gamelists" "/var/config/ES-DE/gamelists" + dir_prep "$rdhome/gamelists" "$XDG_CONFIG_HOME/ES-DE/gamelists" fi fi @@ -128,7 +128,7 @@ prepare_component() { log i "Prepearing Steam ROM Manager" log i "-----------------------------" - local srm_userdata="/var/config/steam-rom-manager/userData" + local srm_userdata="$XDG_CONFIG_HOME/steam-rom-manager/userData" create_dir -d "$srm_userdata" cp -fv "$config/steam-rom-manager/"*.json "$srm_userdata" cp -fvr "$config/steam-rom-manager/manifests" "$srm_userdata" @@ -148,28 +148,28 @@ prepare_component() { if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ $multi_user_mode == "true" ]]; then # Multi-user actions create_dir -d "$multi_user_data_folder/$SteamAppUser/config/retroarch" - cp -fv $config/retroarch/retroarch.cfg "$multi_user_data_folder/$SteamAppUser/config/retroarch/" - cp -fv $config/retroarch/retroarch-core-options.cfg "$multi_user_data_folder/$SteamAppUser/config/retroarch/" + cp -fv "$config/retroarch/retroarch.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/" + cp -fv "$config/retroarch/retroarch-core-options.cfg" "$multi_user_data_folder/$SteamAppUser/config/retroarch/" else # Single-user actions - create_dir -d /var/config/retroarch - dir_prep "$bios_folder" "/var/config/retroarch/system" - dir_prep "$rdhome/logs/retroarch" "/var/config/retroarch/logs" - create_dir -d "/var/config/retroarch/shaders/" - if [[ -d "$cheats_folder/retroarch" && "$(ls -A $cheats_folder/retroarch)" ]]; then + create_dir -d "$XDG_CONFIG_HOME/retroarch" + dir_prep "$bios_folder" "$XDG_CONFIG_HOME/retroarch/system" + dir_prep "$rdhome/logs/retroarch" "$XDG_CONFIG_HOME/retroarch/logs" + create_dir -d "$XDG_CONFIG_HOME/retroarch/shaders/" + if [[ -d "$cheats_folder/retroarch" && "$(ls -A "$cheats_folder/retroarch")" ]]; then backup_file="$backups_folder/cheats/retroarch-$(date +%y%m%d).tar.gz" create_dir "$(dirname "$backup_file")" tar -czf "$backup_file" -C "$cheats_folder" retroarch log i "RetroArch cheats backed up to $backup_file" fi create_dir -d "$cheats_folder/retroarch" - tar --strip-components=1 -xzf /app/retrodeck/cheats/retroarch.tar.gz -C "$cheats_folder/retroarch" --overwrite - cp -rf /app/share/libretro/shaders /var/config/retroarch/ - dir_prep "$shaders_folder/retroarch" "/var/config/retroarch/shaders" - cp -fv $config/retroarch/retroarch.cfg /var/config/retroarch/ - cp -fv $config/retroarch/retroarch-core-options.cfg /var/config/retroarch/ - rsync -rlD --mkpath "$config/retroarch/core-overrides/" "/var/config/retroarch/config/" - rsync -rlD --mkpath "$config/retrodeck/presets/remaps/" "/var/config/retroarch/config/remaps/" - dir_prep "$borders_folder" "/var/config/retroarch/overlays/borders" + tar --strip-components=1 -xzf "/app/retrodeck/cheats/retroarch.tar.gz" -C "$cheats_folder/retroarch" --overwrite + cp -rf "/app/share/libretro/shaders" "$XDG_CONFIG_HOME/retroarch/" + dir_prep "$shaders_folder/retroarch" "$XDG_CONFIG_HOME/retroarch/shaders" + cp -fv "$config/retroarch/retroarch.cfg" "$XDG_CONFIG_HOME/retroarch/" + cp -fv "$config/retroarch/retroarch-core-options.cfg" "$XDG_CONFIG_HOME/retroarch/" + rsync -rlD --mkpath "$config/retroarch/core-overrides/" "$XDG_CONFIG_HOME/retroarch/config/" + rsync -rlD --mkpath "$config/retrodeck/presets/remaps/" "$XDG_CONFIG_HOME/retroarch/config/remaps/" + dir_prep "$borders_folder" "$XDG_CONFIG_HOME/retroarch/overlays/borders" set_setting_value "$raconf" "savefile_directory" "$saves_folder" "retroarch" set_setting_value "$raconf" "savestate_directory" "$states_folder" "retroarch" set_setting_value "$raconf" "screenshot_directory" "$screenshots_folder" "retroarch" @@ -244,9 +244,9 @@ prepare_component() { set_setting_value "$ra_scummvm_conf" "savepath" "$saves_folder/scummvm" "libretro_scummvm" "scummvm" set_setting_value "$ra_scummvm_conf" "browser_lastpath" "$roms_folder/scummvm" "libretro_scummvm" "scummvm" - dir_prep "$texture_packs_folder/RetroArch-Mesen" "/var/config/retroarch/system/HdPacks" - dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/cache" "/var/config/retroarch/system/Mupen64plus/cache" - dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" "/var/config/retroarch/system/Mupen64plus/hires_texture" + dir_prep "$texture_packs_folder/RetroArch-Mesen" "$XDG_CONFIG_HOME/retroarch/system/HdPacks" + dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/cache" "$XDG_CONFIG_HOME/retroarch/system/Mupen64plus/cache" + dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" "$XDG_CONFIG_HOME/retroarch/system/Mupen64plus/hires_texture" # Reset default preset settings set_setting_value "$rd_conf" "retroarch" "$(get_setting_value "$rd_defaults" "retroarch" "retrodeck" "cheevos")" "retrodeck" "cheevos" @@ -272,12 +272,12 @@ prepare_component() { set_setting_value "$rd_conf" "retroarch" "$(get_setting_value "$rd_defaults" "retroarch" "retrodeck" "savestate_auto_save")" "retrodeck" "savestate_auto_save" fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$bios_folder" "/var/config/retroarch/system" - dir_prep "$logs_folder/retroarch" "/var/config/retroarch/logs" - dir_prep "$shaders_folder/retroarch" "/var/config/retroarch/shaders" - dir_prep "$texture_packs_folder/RetroArch-Mesen" "/var/config/retroarch/system/HdPacks" - dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/cache" "/var/config/retroarch/system/Mupen64plus/cache" - dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" "/var/config/retroarch/system/Mupen64plus/hires_texture" + dir_prep "$bios_folder" "$XDG_CONFIG_HOME/retroarch/system" + dir_prep "$logs_folder/retroarch" "$XDG_CONFIG_HOME/retroarch/logs" + dir_prep "$shaders_folder/retroarch" "$XDG_CONFIG_HOME/retroarch/shaders" + dir_prep "$texture_packs_folder/RetroArch-Mesen" "$XDG_CONFIG_HOME/retroarch/system/HdPacks" + dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/cache" "$XDG_CONFIG_HOME/retroarch/system/Mupen64plus/cache" + dir_prep "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" "$XDG_CONFIG_HOME/retroarch/system/Mupen64plus/hires_texture" set_setting_value "$raconf" "savefile_directory" "$saves_folder" "retroarch" set_setting_value "$raconf" "savestate_directory" "$states_folder" "retroarch" set_setting_value "$raconf" "screenshot_directory" "$screenshots_folder" "retroarch" @@ -294,15 +294,15 @@ prepare_component() { log i "------------------------" if [[ $multi_user_mode == "true" ]]; then # Multi-user actions create_dir -d "$multi_user_data_folder/$SteamAppUser/config/citra-emu" - cp -fv $config/citra/qt-config.ini "$multi_user_data_folder/$SteamAppUser/config/citra-emu/qt-config.ini" + cp -fv "$config/citra/qt-config.ini" "$multi_user_data_folder/$SteamAppUser/config/citra-emu/qt-config.ini" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/citra-emu/qt-config.ini" "nand_directory" "$saves_folder/n3ds/citra/nand/" "citra" "Data%20Storage" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/citra-emu/qt-config.ini" "sdmc_directory" "$saves_folder/n3ds/citra/sdmc/" "citra" "Data%20Storage" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/citra-emu/qt-config.ini" "Paths\gamedirs\3\path" "$roms_folder/n3ds" "citra" "UI" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/citra-emu/qt-config.ini" "Paths\screenshotPath" "$screenshots_folder" "citra" "UI" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/citra-emu" "/var/config/citra-emu" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/citra-emu" "$XDG_CONFIG_HOME/citra-emu" else # Single-user actions - create_dir -d /var/config/citra-emu/ - cp -f $config/citra/qt-config.ini /var/config/citra-emu/qt-config.ini + create_dir -d "$XDG_CONFIG_HOME/citra-emu/" + cp -f "$config/citra/qt-config.ini" "$XDG_CONFIG_HOME/citra-emu/qt-config.ini" set_setting_value "$citraconf" "nand_directory" "$saves_folder/n3ds/citra/nand/" "citra" "Data%20Storage" set_setting_value "$citraconf" "sdmc_directory" "$saves_folder/n3ds/citra/sdmc/" "citra" "Data%20Storage" set_setting_value "$citraconf" "Paths\gamedirs\3\path" "$roms_folder/n3ds" "citra" "UI" @@ -311,20 +311,20 @@ prepare_component() { # Shared actions create_dir "$saves_folder/n3ds/citra/nand/" create_dir "$saves_folder/n3ds/citra/sdmc/" - dir_prep "$bios_folder/citra/sysdata" "/var/data/citra-emu/sysdata" - dir_prep "$logs_folder/citra" "/var/data/citra-emu/log" - dir_prep "$mods_folder/Citra" "/var/data/citra-emu/load/mods" - dir_prep "$texture_packs_folder/Citra" "/var/data/citra-emu/load/textures" + dir_prep "$bios_folder/citra/sysdata" "$XDG_DATA_HOME/citra-emu/sysdata" + dir_prep "$logs_folder/citra" "$XDG_DATA_HOME/citra-emu/log" + dir_prep "$mods_folder/Citra" "$XDG_DATA_HOME/citra-emu/load/mods" + dir_prep "$texture_packs_folder/Citra" "$XDG_DATA_HOME/citra-emu/load/textures" # Reset default preset settings set_setting_value "$rd_conf" "citra" "$(get_setting_value "$rd_defaults" "citra" "retrodeck" "abxy_button_swap")" "retrodeck" "abxy_button_swap" set_setting_value "$rd_conf" "citra" "$(get_setting_value "$rd_defaults" "citra" "retrodeck" "ask_to_exit")" "retrodeck" "ask_to_exit" fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$bios_folder/citra/sysdata" "/var/data/citra-emu/sysdata" - dir_prep "$rdhome/logs/citra" "/var/data/citra-emu/log" - dir_prep "$mods_folder/Citra" "/var/data/citra-emu/load/mods" - dir_prep "$texture_packs_folder/Citra" "/var/data/citra-emu/load/textures" + dir_prep "$bios_folder/citra/sysdata" "$XDG_DATA_HOME/citra-emu/sysdata" + dir_prep "$rdhome/logs/citra" "$XDG_DATA_HOME/citra-emu/log" + dir_prep "$mods_folder/Citra" "$XDG_DATA_HOME/citra-emu/load/mods" + dir_prep "$texture_packs_folder/Citra" "$XDG_DATA_HOME/citra-emu/load/textures" set_setting_value "$citraconf" "nand_directory" "$saves_folder/n3ds/citra/nand/" "citra" "Data%20Storage" set_setting_value "$citraconf" "sdmc_directory" "$saves_folder/n3ds/citra/sdmc/" "citra" "Data%20Storage" set_setting_value "$citraconf" "Paths\gamedirs\3\path" "$roms_folder/n3ds" "citra" "UI" @@ -344,10 +344,10 @@ prepare_component() { cp -fr "$config/cemu/"* "$multi_user_data_folder/$SteamAppUser/config/Cemu/" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/Cemu/settings.ini" "mlc_path" "$bios_folder/cemu" "cemu" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/Cemu/settings.ini" "Entry" "$roms_folder/wiiu" "cemu" "GamePaths" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/Cemu" "/var/config/Cemu" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/Cemu" "$XDG_CONFIG_HOME/Cemu" else - create_dir -d /var/config/Cemu/ - cp -fr "$config/cemu/"* /var/config/Cemu/ + create_dir -d "$XDG_CONFIG_HOME/Cemu/" + cp -fr "$config/cemu/"* "$XDG_CONFIG_HOME/Cemu/" set_setting_value "$cemuconf" "mlc_path" "$bios_folder/cemu" "cemu" set_setting_value "$cemuconf" "Entry" "$roms_folder/wiiu" "cemu" "GamePaths" if [[ -e "$bios_folder/cemu/keys.txt" ]]; then @@ -378,10 +378,10 @@ prepare_component() { set_setting_value "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu/Dolphin.ini" "ISOPath0" "$roms_folder/wii" "dolphin" "General" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu/Dolphin.ini" "ISOPath1" "$roms_folder/gc" "dolphin" "General" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu/Dolphin.ini" "WiiSDCardPath" "$saves_folder/wii/dolphin/sd.raw" "dolphin" "General" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu" "/var/config/dolphin-emu" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu" "$XDG_CONFIG_HOME/dolphin-emu" else # Single-user actions - create_dir -d /var/config/dolphin-emu/ - cp -fvr "$config/dolphin/"* /var/config/dolphin-emu/ + create_dir -d "$XDG_CONFIG_HOME/dolphin-emu/" + cp -fvr "$config/dolphin/"* "$XDG_CONFIG_HOME/dolphin-emu/" set_setting_value "$dolphinconf" "BIOS" "$bios_folder" "dolphin" "GBA" set_setting_value "$dolphinconf" "SavesPath" "$saves_folder/gba" "dolphin" "GBA" set_setting_value "$dolphinconf" "ISOPath0" "$roms_folder/wii" "dolphin" "General" @@ -389,27 +389,27 @@ prepare_component() { set_setting_value "$dolphinconf" "WiiSDCardPath" "$saves_folder/wii/dolphin/sd.raw" "dolphin" "General" fi # Shared actions - dir_prep "$saves_folder/gc/dolphin/EU" "/var/data/dolphin-emu/GC/EUR" # TODO: Multi-user one-off - dir_prep "$saves_folder/gc/dolphin/US" "/var/data/dolphin-emu/GC/USA" # TODO: Multi-user one-off - dir_prep "$saves_folder/gc/dolphin/JP" "/var/data/dolphin-emu/GC/JAP" # TODO: Multi-user one-off - dir_prep "$screenshots_folder" "/var/data/dolphin-emu/ScreenShots" - dir_prep "$states_folder/dolphin" "/var/data/dolphin-emu/StateSaves" - dir_prep "$saves_folder/wii/dolphin" "/var/data/dolphin-emu/Wii" - dir_prep "$mods_folder/Dolphin" "/var/data/dolphin-emu/Load/GraphicMods" - dir_prep "$texture_packs_folder/Dolphin" "/var/data/dolphin-emu/Load/Textures" + dir_prep "$saves_folder/gc/dolphin/EU" "$XDG_DATA_HOME/dolphin-emu/GC/EUR" # TODO: Multi-user one-off + dir_prep "$saves_folder/gc/dolphin/US" "$XDG_DATA_HOME/dolphin-emu/GC/USA" # TODO: Multi-user one-off + dir_prep "$saves_folder/gc/dolphin/JP" "$XDG_DATA_HOME/dolphin-emu/GC/JAP" # TODO: Multi-user one-off + dir_prep "$screenshots_folder" "$XDG_DATA_HOME/dolphin-emu/ScreenShots" + dir_prep "$states_folder/dolphin" "$XDG_DATA_HOME/dolphin-emu/StateSaves" + dir_prep "$saves_folder/wii/dolphin" "$XDG_DATA_HOME/dolphin-emu/Wii" + dir_prep "$mods_folder/Dolphin" "$XDG_DATA_HOME/dolphin-emu/Load/GraphicMods" + dir_prep "$texture_packs_folder/Dolphin" "$XDG_DATA_HOME/dolphin-emu/Load/Textures" # Reset default preset settings set_setting_value "$rd_conf" "dolphin" "$(get_setting_value "$rd_defaults" "dolphin" "retrodeck" "ask_to_exit")" "retrodeck" "ask_to_exit" fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$saves_folder/gc/dolphin/EU" "/var/data/dolphin-emu/GC/EUR" - dir_prep "$saves_folder/gc/dolphin/US" "/var/data/dolphin-emu/GC/USA" - dir_prep "$saves_folder/gc/dolphin/JP" "/var/data/dolphin-emu/GC/JAP" - dir_prep "$screenshots_folder" "/var/data/dolphin-emu/ScreenShots" - dir_prep "$states_folder/dolphin" "/var/data/dolphin-emu/StateSaves" - dir_prep "$saves_folder/wii/dolphin" "/var/data/dolphin-emu/Wii" - dir_prep "$mods_folder/Dolphin" "/var/data/dolphin-emu/Load/GraphicMods" - dir_prep "$texture_packs_folder/Dolphin" "/var/data/dolphin-emu/Load/Textures" + dir_prep "$saves_folder/gc/dolphin/EU" "$XDG_DATA_HOME/dolphin-emu/GC/EUR" + dir_prep "$saves_folder/gc/dolphin/US" "$XDG_DATA_HOME/dolphin-emu/GC/USA" + dir_prep "$saves_folder/gc/dolphin/JP" "$XDG_DATA_HOME/dolphin-emu/GC/JAP" + dir_prep "$screenshots_folder" "$XDG_DATA_HOME/dolphin-emu/ScreenShots" + dir_prep "$states_folder/dolphin" "$XDG_DATA_HOME/dolphin-emu/StateSaves" + dir_prep "$saves_folder/wii/dolphin" "$XDG_DATA_HOME/dolphin-emu/Wii" + dir_prep "$mods_folder/Dolphin" "$XDG_DATA_HOME/dolphin-emu/Load/GraphicMods" + dir_prep "$texture_packs_folder/Dolphin" "$XDG_DATA_HOME/dolphin-emu/Load/Textures" set_setting_value "$dolphinconf" "BIOS" "$bios_folder" "dolphin" "GBA" set_setting_value "$dolphinconf" "SavesPath" "$saves_folder/gba" "dolphin" "GBA" set_setting_value "$dolphinconf" "ISOPath0" "$roms_folder/wii" "dolphin" "General" @@ -432,11 +432,11 @@ prepare_component() { set_setting_value "$multi_user_data_folder/$SteamAppUser/data/duckstation/settings.ini" "Card2Path" "$saves_folder/psx/duckstation/memcards/shared_card_2.mcd" "duckstation" "MemoryCards" set_setting_value "$multi_user_data_folder/$SteamAppUser/data/duckstation/settings.ini" "Directory" "$saves_folder/psx/duckstation/memcards" "duckstation" "MemoryCards" set_setting_value "$multi_user_data_folder/$SteamAppUser/data/duckstation/settings.ini" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/duckstation" "/var/config/duckstation" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/duckstation" "$XDG_CONFIG_HOME/duckstation" else # Single-user actions - create_dir -d "/var/config/duckstation/" + create_dir -d "$XDG_CONFIG_HOME/duckstation/" create_dir "$saves_folder/psx/duckstation/memcards" - cp -fv "$config/duckstation/"* /var/config/duckstation + cp -fv "$config/duckstation/"* "$XDG_CONFIG_HOME/duckstation" set_setting_value "$duckstationconf" "SearchDirectory" "$bios_folder" "duckstation" "BIOS" set_setting_value "$duckstationconf" "Card1Path" "$saves_folder/psx/duckstation/memcards/shared_card_1.mcd" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "Card2Path" "$saves_folder/psx/duckstation/memcards/shared_card_2.mcd" "duckstation" "MemoryCards" @@ -444,8 +444,8 @@ prepare_component() { set_setting_value "$duckstationconf" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList" fi # Shared actions - dir_prep "$states_folder/psx/duckstation" "/var/config/duckstation/savestates" # This is hard-coded in Duckstation, always needed - dir_prep "$texture_packs_folder/Duckstation" "/var/config/duckstation/textures" + dir_prep "$states_folder/psx/duckstation" "$XDG_CONFIG_HOME/duckstation/savestates" # This is hard-coded in Duckstation, always needed + dir_prep "$texture_packs_folder/Duckstation" "$XDG_CONFIG_HOME/duckstation/textures" # Reset default preset settings set_setting_value "$rd_conf" "duckstation" "$(get_setting_value "$rd_defaults" "duckstation" "retrodeck" "cheevos")" "retrodeck" "cheevos" @@ -459,8 +459,8 @@ prepare_component() { set_setting_value "$duckstationconf" "Card2Path" "$saves_folder/psx/duckstation/memcards/shared_card_2.mcd" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "Directory" "$saves_folder/psx/duckstation/memcards" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList" - dir_prep "$states_folder/psx/duckstation" "/var/config/duckstation/savestates" # This is hard-coded in Duckstation, always needed - dir_prep "$texture_packs_folder/Duckstation" "/var/config/duckstation/textures" + dir_prep "$states_folder/psx/duckstation" "$XDG_CONFIG_HOME/duckstation/savestates" # This is hard-coded in Duckstation, always needed + dir_prep "$texture_packs_folder/Duckstation" "$XDG_CONFIG_HOME/duckstation/textures" fi fi @@ -472,16 +472,16 @@ prepare_component() { log i "----------------------" if [[ $multi_user_mode == "true" ]]; then # Multi-user actions create_dir -d "$multi_user_data_folder/$SteamAppUser/config/melonDS/" - cp -fvr $config/melonds/melonDS.ini "$multi_user_data_folder/$SteamAppUser/config/melonDS/" + cp -fvr "$config/melonds/melonDS.ini" "$multi_user_data_folder/$SteamAppUser/config/melonDS/" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/melonDS/melonDS.ini" "BIOS9Path" "$bios_folder/bios9.bin" "melonds" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/melonDS/melonDS.ini" "BIOS7Path" "$bios_folder/bios7.bin" "melonds" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/melonDS/melonDS.ini" "FirmwarePath" "$bios_folder/firmware.bin" "melonds" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/melonDS/melonDS.ini" "SaveFilePath" "$saves_folder/nds/melonds" "melonds" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/melonDS/melonDS.ini" "SavestatePath" "$states_folder/nds/melonds" "melonds" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/melonDS" "/var/config/melonDS" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/melonDS" "$XDG_CONFIG_HOME/melonDS" else # Single-user actions - create_dir -d /var/config/melonDS/ - cp -fvr $config/melonds/melonDS.ini /var/config/melonDS/ + create_dir -d "$XDG_CONFIG_HOME/melonDS/" + cp -fvr "$config/melonds/melonDS.ini" "$XDG_CONFIG_HOME/melonDS/" set_setting_value "$melondsconf" "BIOS9Path" "$bios_folder/bios9.bin" "melonds" set_setting_value "$melondsconf" "BIOS7Path" "$bios_folder/bios7.bin" "melonds" set_setting_value "$melondsconf" "FirmwarePath" "$bios_folder/firmware.bin" "melonds" @@ -491,10 +491,10 @@ prepare_component() { # Shared actions create_dir "$saves_folder/nds/melonds" create_dir "$states_folder/nds/melonds" - dir_prep "$bios_folder" "/var/config/melonDS/bios" + dir_prep "$bios_folder" "$XDG_CONFIG_HOME/melonDS/bios" fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$bios_folder" "/var/config/melonDS/bios" + dir_prep "$bios_folder" "$XDG_CONFIG_HOME/melonDS/bios" set_setting_value "$melondsconf" "BIOS9Path" "$bios_folder/bios9.bin" "melonds" set_setting_value "$melondsconf" "BIOS7Path" "$bios_folder/bios7.bin" "melonds" set_setting_value "$melondsconf" "FirmwarePath" "$bios_folder/firmware.bin" "melonds" @@ -517,29 +517,29 @@ prepare_component() { set_setting_value "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis/PCSX2.ini" "SaveStates" "$states_folder/ps2/pcsx2" "pcsx2" "Folders" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis/PCSX2.ini" "MemoryCards" "$saves_folder/ps2/pcsx2/memcards" "pcsx2" "Folders" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis/PCSX2.ini" "RecursivePaths" "$roms_folder/ps2" "pcsx2" "GameList" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/PCSX2" "/var/config/PCSX2" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/PCSX2" "$XDG_CONFIG_HOME/PCSX2" else # Single-user actions - create_dir -d "/var/config/PCSX2/inis" - cp -fvr "$config/PCSX2/"* /var/config/PCSX2/inis/ + create_dir -d "$XDG_CONFIG_HOME/PCSX2/inis" + cp -fvr "$config/PCSX2/"* "$XDG_CONFIG_HOME/PCSX2/inis/" set_setting_value "$pcsx2conf" "Bios" "$bios_folder" "pcsx2" "Folders" set_setting_value "$pcsx2conf" "Snapshots" "$screenshots_folder" "pcsx2" "Folders" set_setting_value "$pcsx2conf" "SaveStates" "$states_folder/ps2/pcsx2" "pcsx2" "Folders" set_setting_value "$pcsx2conf" "MemoryCards" "$saves_folder/ps2/pcsx2/memcards" "pcsx2" "Folders" set_setting_value "$pcsx2conf" "RecursivePaths" "$roms_folder/ps2" "pcsx2" "GameList" set_setting_value "$pcsx2conf" "Cheats" "$cheats_folder/pcsx2" "Folders" - if [[ -d "$cheats_folder/pcsx2" && "$(ls -A $cheats_folder/pcsx2)" ]]; then + if [[ -d "$cheats_folder/pcsx2" && "$(ls -A "$cheats_folder/pcsx2")" ]]; then backup_file="$backups_folder/cheats/pcsx2-$(date +%y%m%d).tar.gz" - create_dir "$(dirname $backup_file)" + create_dir "$(dirname "$backup_file")" tar -czf "$backup_file" -C "$cheats_folder" pcsx2 log i "PCSX2 cheats backed up to $backup_file" fi create_dir -d "$cheats_folder/pcsx2" - tar --strip-components=1 -xzf /app/retrodeck/cheats/pcsx2.tar.gz -C "$cheats_folder/pcsx2" --overwrite + tar --strip-components=1 -xzf "/app/retrodeck/cheats/pcsx2.tar.gz" -C "$cheats_folder/pcsx2" --overwrite fi # Shared actions create_dir "$saves_folder/ps2/pcsx2/memcards" create_dir "$states_folder/ps2/pcsx2" - dir_prep "$texture_packs_folder/PCSX2" "/var/config/PCSX2/textures" + dir_prep "$texture_packs_folder/PCSX2" "$XDG_CONFIG_HOME/PCSX2/textures" # Reset default preset settings set_setting_value "$rd_conf" "pcsx2" "$(get_setting_value "$rd_defaults" "pcsx2" "retrodeck" "cheevos")" "retrodeck" "cheevos" @@ -554,7 +554,7 @@ prepare_component() { set_setting_value "$pcsx2conf" "MemoryCards" "$saves_folder/ps2/pcsx2/memcards" "pcsx2" "Folders" set_setting_value "$pcsx2conf" "RecursivePaths" "$roms_folder/ps2" "pcsx2" "GameList" set_setting_value "$pcsx2conf" "Cheats" "$cheats_folder/pcsx2" "Folders" - dir_prep "$texture_packs_folder/PCSX2" "/var/config/PCSX2/textures" + dir_prep "$texture_packs_folder/PCSX2" "$XDG_CONFIG_HOME/PCSX2/textures" fi fi @@ -581,25 +581,25 @@ prepare_component() { create_dir -d "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/" cp -fv "$config/ppssppsdl/"* "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/ppsspp.ini" "CurrentDirectory" "$roms_folder/psp" "ppsspp" "General" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/ppsspp" "/var/config/ppsspp" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/ppsspp" "$XDG_CONFIG_HOME/ppsspp" else # Single-user actions - create_dir -d /var/config/ppsspp/PSP/SYSTEM/ - cp -fv "$config/ppssppsdl/"* /var/config/ppsspp/PSP/SYSTEM/ + create_dir -d "$XDG_CONFIG_HOME/ppsspp/PSP/SYSTEM/" + cp -fv "$config/ppssppsdl/"* "$XDG_CONFIG_HOME/ppsspp/PSP/SYSTEM/" set_setting_value "$ppssppconf" "CurrentDirectory" "$roms_folder/psp" "ppsspp" "General" fi # Shared actions - dir_prep "$saves_folder/PSP/PPSSPP-SA" "/var/config/ppsspp/PSP/SAVEDATA" - dir_prep "$states_folder/PSP/PPSSPP-SA" "/var/config/ppsspp/PSP/PPSSPP_STATE" - dir_prep "$texture_packs_folder/PPSSPP" "/var/config/ppsspp/PSP/TEXTURES" + dir_prep "$saves_folder/PSP/PPSSPP-SA" "$XDG_CONFIG_HOME/ppsspp/PSP/SAVEDATA" + dir_prep "$states_folder/PSP/PPSSPP-SA" "$XDG_CONFIG_HOME/ppsspp/PSP/PPSSPP_STATE" + dir_prep "$texture_packs_folder/PPSSPP" "$XDG_CONFIG_HOME/ppsspp/PSP/TEXTURES" create_dir -d "$cheats_folder/PPSSPP" - dir_prep "$cheats_folder/PPSSPP" "/var/config/ppsspp/PSP/Cheats" + dir_prep "$cheats_folder/PPSSPP" "$XDG_CONFIG_HOME/ppsspp/PSP/Cheats" if [[ -d "$cheats_folder/PPSSPP" && "$(ls -A "$cheats_folder"/PPSSPP)" ]]; then backup_file="$backups_folder/cheats/PPSSPP-$(date +%y%m%d).tar.gz" create_dir "$(dirname "$backup_file")" tar -czf "$backup_file" -C "$cheats_folder" PPSSPP log i "PPSSPP cheats backed up to $backup_file" fi - tar -xzf /app/retrodeck/cheats/ppsspp.tar.gz -C "$cheats_folder/PPSSPP" --overwrite + tar -xzf "/app/retrodeck/cheats/ppsspp.tar.gz" -C "$cheats_folder/PPSSPP" --overwrite # Reset default preset settings set_setting_value "$rd_conf" "ppsspp" "$(get_setting_value "$rd_defaults" "ppsspp" "retrodeck" "cheevos")" "retrodeck" "cheevos" @@ -607,10 +607,10 @@ prepare_component() { fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands set_setting_value "$ppssppconf" "CurrentDirectory" "$roms_folder/psp" "ppsspp" "General" - dir_prep "$saves_folder/PSP/PPSSPP-SA" "/var/config/ppsspp/PSP/SAVEDATA" - dir_prep "$states_folder/PSP/PPSSPP-SA" "/var/config/ppsspp/PSP/PPSSPP_STATE" - dir_prep "$texture_packs_folder/PPSSPP" "/var/config/ppsspp/PSP/TEXTURES" - dir_prep "$cheats_folder/PPSSPP" "/var/config/ppsspp/PSP/Cheats" + dir_prep "$saves_folder/PSP/PPSSPP-SA" "$XDG_CONFIG_HOME/ppsspp/PSP/SAVEDATA" + dir_prep "$states_folder/PSP/PPSSPP-SA" "$XDG_CONFIG_HOME/ppsspp/PSP/PPSSPP_STATE" + dir_prep "$texture_packs_folder/PPSSPP" "$XDG_CONFIG_HOME/ppsspp/PSP/TEXTURES" + dir_prep "$cheats_folder/PPSSPP" "$XDG_CONFIG_HOME/ppsspp/PSP/Cheats" fi fi @@ -623,25 +623,25 @@ prepare_component() { if [[ $multi_user_mode == "true" ]]; then # Multi-user actions create_dir -d "$multi_user_data_folder/$SteamAppUser/config/primehack" cp -fvr "$config/primehack/config/"* "$multi_user_data_folder/$SteamAppUser/config/primehack/" - set_setting_value ""$multi_user_data_folder/$SteamAppUser/config/primehack/Dolphin.ini"" "ISOPath0" "$roms_folder/wii" "primehack" "General" - set_setting_value ""$multi_user_data_folder/$SteamAppUser/config/primehack/Dolphin.ini"" "ISOPath1" "$roms_folder/gc" "primehack" "General" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/primehack" "/var/config/primehack" + set_setting_value "$multi_user_data_folder/$SteamAppUser/config/primehack/Dolphin.ini" "ISOPath0" "$roms_folder/wii" "primehack" "General" + set_setting_value "$multi_user_data_folder/$SteamAppUser/config/primehack/Dolphin.ini" "ISOPath1" "$roms_folder/gc" "primehack" "General" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/primehack" "$XDG_CONFIG_HOME/primehack" else # Single-user actions - create_dir -d /var/config/primehack/ - cp -fvr "$config/primehack/config/"* /var/config/primehack/ + create_dir -d "$XDG_CONFIG_HOME/primehack/" + cp -fvr "$config/primehack/config/"* "$XDG_CONFIG_HOME/primehack/" set_setting_value "$primehackconf" "ISOPath0" "$roms_folder/wii" "primehack" "General" set_setting_value "$primehackconf" "ISOPath1" "$roms_folder/gc" "primehack" "General" fi # Shared actions - dir_prep "$saves_folder/gc/primehack/EU" "/var/data/primehack/GC/EUR" - dir_prep "$saves_folder/gc/primehack/US" "/var/data/primehack/GC/USA" - dir_prep "$saves_folder/gc/primehack/JP" "/var/data/primehack/GC/JAP" - dir_prep "$screenshots_folder" "/var/data/primehack/ScreenShots" - dir_prep "$states_folder/primehack" "/var/data/primehack/StateSaves" - create_dir /var/data/primehack/Wii/ - dir_prep "$saves_folder/wii/primehack" "/var/data/primehack/Wii" - dir_prep "$mods_folder/Primehack" "/var/data/primehack/Load/GraphicMods" - dir_prep "$texture_packs_folder/Primehack" "/var/data/primehack/Load/Textures" + dir_prep "$saves_folder/gc/primehack/EU" "$XDG_DATA_HOME/primehack/GC/EUR" + dir_prep "$saves_folder/gc/primehack/US" "$XDG_DATA_HOME/primehack/GC/USA" + dir_prep "$saves_folder/gc/primehack/JP" "$XDG_DATA_HOME/primehack/GC/JAP" + dir_prep "$screenshots_folder" "$XDG_DATA_HOME/primehack/ScreenShots" + dir_prep "$states_folder/primehack" "$XDG_DATA_HOME/primehack/StateSaves" + create_dir "$XDG_DATA_HOME/primehack/Wii/" + dir_prep "$saves_folder/wii/primehack" "$XDG_DATA_HOME/primehack/Wii" + dir_prep "$mods_folder/Primehack" "$XDG_DATA_HOME/primehack/Load/GraphicMods" + dir_prep "$texture_packs_folder/Primehack" "$XDG_DATA_HOME/primehack/Load/Textures" if [[ $multi_user_mode == "true" ]]; then # Multi-user actions cp -fvr "$config/primehack/data/"* "$multi_user_data_folder/$SteamAppUser/data/primehack/" # this must be done after the dirs are prepared as it copying some "mods" fi @@ -650,14 +650,14 @@ prepare_component() { set_setting_value "$rd_conf" "primehack" "$(get_setting_value "$rd_defaults" "primehack" "retrodeck" "ask_to_exit")" "retrodeck" "ask_to_exit" fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$saves_folder/gc/primehack/EU" "/var/data/primehack/GC/EUR" - dir_prep "$saves_folder/gc/primehack/US" "/var/data/primehack/GC/USA" - dir_prep "$saves_folder/gc/primehack/JP" "/var/data/primehack/GC/JAP" - dir_prep "$screenshots_folder" "/var/data/primehack/ScreenShots" - dir_prep "$states_folder/primehack" "/var/data/primehack/StateSaves" - dir_prep "$saves_folder/wii/primehack" "/var/data/primehack/Wii/" - dir_prep "$mods_folder/Primehack" "/var/data/primehack/Load/GraphicMods" - dir_prep "$texture_packs_folder/Primehack" "/var/data/primehack/Load/Textures" + dir_prep "$saves_folder/gc/primehack/EU" "$XDG_DATA_HOME/primehack/GC/EUR" + dir_prep "$saves_folder/gc/primehack/US" "$XDG_DATA_HOME/primehack/GC/USA" + dir_prep "$saves_folder/gc/primehack/JP" "$XDG_DATA_HOME/primehack/GC/JAP" + dir_prep "$screenshots_folder" "$XDG_DATA_HOME/primehack/ScreenShots" + dir_prep "$states_folder/primehack" "$XDG_DATA_HOME/primehack/StateSaves" + dir_prep "$saves_folder/wii/primehack" "$XDG_DATA_HOME/primehack/Wii/" + dir_prep "$mods_folder/Primehack" "$XDG_DATA_HOME/primehack/Load/GraphicMods" + dir_prep "$texture_packs_folder/Primehack" "$XDG_DATA_HOME/primehack/Load/Textures" set_setting_value "$primehackconf" "ISOPath0" "$roms_folder/gc" "primehack" "General" fi fi @@ -674,15 +674,15 @@ prepare_component() { # This is an unfortunate one-off because set_setting_value does not currently support settings with $ in the name. sed -i 's^\^$(EmulatorDir): .*^$(EmulatorDir): '"$bios_folder/rpcs3/"'^' "$multi_user_data_folder/$SteamAppUser/config/rpcs3/vfs.yml" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/rpcs3/vfs.yml" "/games/" "$roms_folder/ps3/" "rpcs3" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/rpcs3" "/var/config/rpcs3" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/rpcs3" "$XDG_CONFIG_HOME/rpcs3" else # Single-user actions - create_dir -d /var/config/rpcs3/ - cp -fr "$config/rpcs3/"* /var/config/rpcs3/ + create_dir -d "$XDG_CONFIG_HOME/rpcs3/" + cp -fr "$config/rpcs3/"* "$XDG_CONFIG_HOME/rpcs3/" # This is an unfortunate one-off because set_setting_value does not currently support settings with $ in the name. sed -i 's^\^$(EmulatorDir): .*^$(EmulatorDir): '"$bios_folder/rpcs3/"'^' "$rpcs3vfsconf" set_setting_value "$rpcs3vfsconf" "/games/" "$roms_folder/ps3/" "rpcs3" dir_prep "$saves_folder/ps3/rpcs3" "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata" - dir_prep "$states_folder/ps3/rpcs3" "/var/config/rpcs3/savestates" + dir_prep "$states_folder/ps3/rpcs3" "$XDG_CONFIG_HOME/rpcs3/savestates" fi # Shared actions create_dir "$bios_folder/rpcs3/dev_hdd0" @@ -711,16 +711,16 @@ prepare_component() { if [[ $multi_user_mode == "true" ]]; then rm -rf "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" #create_dir "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/system" - cp -fv $config/ryujinx/* "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" + cp -fv "$config/ryujinx/"* "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/Config.json" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" "/var/config/Ryujinx" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" "$XDG_CONFIG_HOME/Ryujinx" else # removing config directory to wipe legacy files - log d "Removing \"/var/config/Ryujinx\"" - rm -rf "/var/config/Ryujinx" - create_dir "/var/config/Ryujinx/system" + log d "Removing \"$XDG_CONFIG_HOME/Ryujinx\"" + rm -rf "$XDG_CONFIG_HOME/Ryujinx" + create_dir "$XDG_CONFIG_HOME/Ryujinx/system" cp -fv "$config/ryujinx/Config.json" "$ryujinxconf" - cp -fvr "$config/ryujinx/profiles" "/var/config/Ryujinx/" + cp -fvr "$config/ryujinx/profiles" "$XDG_CONFIG_HOME/Ryujinx/" log d "Replacing placeholders in \"$ryujinxconf\"" sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$ryujinxconf" create_dir "$logs_folder/ryujinx" @@ -729,11 +729,11 @@ prepare_component() { fi fi # if [[ "$action" == "reset" ]] || [[ "$action" == "postmove" ]]; then # Run commands that apply to both resets and moves - # dir_prep "$bios_folder/switch/keys" "/var/config/Ryujinx/system" + # dir_prep "$bios_folder/switch/keys" "$XDG_CONFIG_HOME/Ryujinx/system" # fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands log d "Replacing placeholders in \"$ryujinxconf\"" - sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$ryujinxconf" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$ryujinxconf" # This is an unfortunate one-off because set_setting_value does not currently support JSON fi fi @@ -751,26 +751,26 @@ prepare_component() { set_setting_value "$multi_user_data_folder/$SteamAppUser/config/yuzu/qt-config.ini" "sdmc_directory" "$saves_folder/switch/yuzu/sdmc" "yuzu" "Data%20Storage" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/yuzu/qt-config.ini" "Paths\gamedirs\4\path" "$roms_folder/switch" "yuzu" "UI" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/yuzu/qt-config.ini" "Screenshots\screenshot_path" "$screenshots_folder" "yuzu" "UI" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/yuzu" "/var/config/yuzu" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/yuzu" "$XDG_CONFIG_HOME/yuzu" else # Single-user actions - create_dir -d /var/config/yuzu/ - cp -fvr "$config/yuzu/"* /var/config/yuzu/ + create_dir -d "$XDG_CONFIG_HOME/yuzu/" + cp -fvr "$config/yuzu/"* "$XDG_CONFIG_HOME/yuzu/" set_setting_value "$yuzuconf" "nand_directory" "$saves_folder/switch/yuzu/nand" "yuzu" "Data%20Storage" set_setting_value "$yuzuconf" "sdmc_directory" "$saves_folder/switch/yuzu/sdmc" "yuzu" "Data%20Storage" set_setting_value "$yuzuconf" "Paths\gamedirs\4\path" "$roms_folder/switch" "yuzu" "UI" set_setting_value "$yuzuconf" "Screenshots\screenshot_path" "$screenshots_folder" "yuzu" "UI" fi # Shared actions - dir_prep "$saves_folder/switch/yuzu/nand" "/var/data/yuzu/nand" - dir_prep "$saves_folder/switch/yuzu/sdmc" "/var/data/yuzu/sdmc" - dir_prep "$bios_folder/switch/keys" "/var/data/yuzu/keys" - dir_prep "$bios_folder/switch/firmware" "/var/data/yuzu/nand/system/Contents/registered" - dir_prep "$logs_folder/yuzu" "/var/data/yuzu/log" - dir_prep "$screenshots_folder" "/var/data/yuzu/screenshots" - dir_prep "$mods_folder/Yuzu" "/var/data/yuzu/load" + dir_prep "$saves_folder/switch/yuzu/nand" "$XDG_DATA_HOME/yuzu/nand" + dir_prep "$saves_folder/switch/yuzu/sdmc" "$XDG_DATA_HOME/yuzu/sdmc" + dir_prep "$bios_folder/switch/keys" "$XDG_DATA_HOME/yuzu/keys" + dir_prep "$bios_folder/switch/firmware" "$XDG_DATA_HOME/yuzu/nand/system/Contents/registered" + dir_prep "$logs_folder/yuzu" "$XDG_DATA_HOME/yuzu/log" + dir_prep "$screenshots_folder" "$XDG_DATA_HOME/yuzu/screenshots" + dir_prep "$mods_folder/Yuzu" "$XDG_DATA_HOME/yuzu/load" # removing dead symlinks as they were present in a past version - if [ -d $bios_folder/switch ]; then - find $bios_folder/switch -xtype l -exec rm {} \; + if [ -d "$bios_folder/switch" ]; then + find "$bios_folder/switch" -xtype l -exec rm {} \; fi # Reset default preset settings @@ -778,13 +778,13 @@ prepare_component() { set_setting_value "$rd_conf" "yuzu" "$(get_setting_value "$rd_defaults" "yuzu" "retrodeck" "ask_to_exit")" "retrodeck" "ask_to_exit" fi if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$bios_folder/switch/keys" "/var/data/yuzu/keys" - dir_prep "$bios_folder/switch/firmware" "/var/data/yuzu/nand/system/Contents/registered" - dir_prep "$saves_folder/switch/yuzu/nand" "/var/data/yuzu/nand" - dir_prep "$saves_folder/switch/yuzu/sdmc" "/var/data/yuzu/sdmc" - dir_prep "$logs_folder/yuzu" "/var/data/yuzu/log" - dir_prep "$screenshots_folder" "/var/data/yuzu/screenshots" - dir_prep "$mods_folder/Yuzu" "/var/data/yuzu/load" + dir_prep "$bios_folder/switch/keys" "$XDG_DATA_HOME/yuzu/keys" + dir_prep "$bios_folder/switch/firmware" "$XDG_DATA_HOME/yuzu/nand/system/Contents/registered" + dir_prep "$saves_folder/switch/yuzu/nand" "$XDG_DATA_HOME/yuzu/nand" + dir_prep "$saves_folder/switch/yuzu/sdmc" "$XDG_DATA_HOME/yuzu/sdmc" + dir_prep "$logs_folder/yuzu" "$XDG_DATA_HOME/yuzu/log" + dir_prep "$screenshots_folder" "$XDG_DATA_HOME/yuzu/screenshots" + dir_prep "$mods_folder/Yuzu" "$XDG_DATA_HOME/yuzu/load" set_setting_value "$yuzuconf" "nand_directory" "$saves_folder/switch/yuzu/nand" "yuzu" "Data%20Storage" set_setting_value "$yuzuconf" "sdmc_directory" "$saves_folder/switch/yuzu/sdmc" "yuzu" "Data%20Storage" set_setting_value "$yuzuconf" "Paths\gamedirs\4\path" "$roms_folder/switch" "yuzu" "UI" @@ -800,8 +800,8 @@ prepare_component() { log i "Prepearing XEMU" log i "------------------------" if [[ $multi_user_mode == "true" ]]; then # Multi-user actions - rm -rf "/var/config/xemu" - rm -rf "/var/data/xemu" + rm -rf "$XDG_CONFIG_HOME/xemu" + rm -rf "$XDG_DATA_HOME/xemu" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/xemu/" cp -fv "$config/xemu/xemu.toml" "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "screenshot_dir" "'$screenshots_folder'" "xemu" "General" @@ -809,12 +809,12 @@ prepare_component() { set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "flashrom_path" "'$bios_folder/Complex.bin'" "xemu" "sys.files" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "eeprom_path" "'$saves_folder/xbox/xemu/xbox-eeprom.bin'" "xemu" "sys.files" set_setting_value "$multi_user_data_folder/$SteamAppUser/config/xemu/xemu.toml" "hdd_path" "'$bios_folder/xbox_hdd.qcow2'" "xemu" "sys.files" - dir_prep "$multi_user_data_folder/$SteamAppUser/config/xemu" "/var/config/xemu" # Creating config folder in /var/config for consistentcy and linking back to original location where component will look - dir_prep "$multi_user_data_folder/$SteamAppUser/config/xemu" "/var/data/xemu/xemu" + dir_prep "$multi_user_data_folder/$SteamAppUser/config/xemu" "$XDG_CONFIG_HOME/xemu" # Creating config folder in $XDG_CONFIG_HOME for consistentcy and linking back to original location where component will look + dir_prep "$multi_user_data_folder/$SteamAppUser/config/xemu" "$XDG_DATA_HOME/xemu/xemu" else # Single-user actions - rm -rf "/var/config/xemu" - rm -rf "/var/data/xemu" - dir_prep "/var/config/xemu" "/var/data/xemu/xemu" # Creating config folder in /var/config for consistentcy and linking back to original location where component will look + rm -rf "$XDG_CONFIG_HOME/xemu" + rm -rf "$XDG_DATA_HOME/xemu" + dir_prep "$XDG_CONFIG_HOME/xemu" "$XDG_DATA_HOME/xemu/xemu" # Creating config folder in $XDG_CONFIG_HOME for consistentcy and linking back to original location where component will look cp -fv "$config/xemu/xemu.toml" "$xemuconf" set_setting_value "$xemuconf" "screenshot_dir" "'$screenshots_folder'" "xemu" "General" set_setting_value "$xemuconf" "bootrom_path" "'$bios_folder/mcpx_1.0.bin'" "xemu" "sys.files" @@ -848,8 +848,8 @@ prepare_component() { log d "Figure out what Vita3k needs for multi-user" else # Single-user actions # NOTE: the component is writing in "." so it must be placed in the rw filesystem. A symlink of the binary is already placed in /app/bin/Vita3K - rm -rf "/var/config/Vita3K" - create_dir "/var/config/Vita3K" + rm -rf "$XDG_CONFIG_HOME/Vita3K" + create_dir "$XDG_CONFIG_HOME/Vita3K" cp -fvr "$config/vita3k/config.yml" "$vita3kconf" # component config cp -fvr "$config/vita3k/ux0" "$bios_folder/Vita3K/" # User config set_setting_value "$vita3kconf" "pref-path" "$bios_folder/Vita3K/" "vita3k" @@ -878,45 +878,45 @@ prepare_component() { create_dir "$rdhome/screenshots/mame-sa" create_dir "$saves_folder/mame-sa/diff" - create_dir "/var/config/ctrlr" - create_dir "/var/config/mame/ini" - create_dir "/var/config/mame/cfg" - create_dir "/var/config/mame/inp" + create_dir "$XDG_CONFIG_HOME/ctrlr" + create_dir "$XDG_CONFIG_HOME/mame/ini" + create_dir "$XDG_CONFIG_HOME/mame/cfg" + create_dir "$XDG_CONFIG_HOME/mame/inp" - create_dir "/var/data/mame/plugin-data" - create_dir "/var/data/mame/hash" + create_dir "$XDG_DATA_HOME/mame/plugin-data" + create_dir "$XDG_DATA_HOME/mame/hash" create_dir "$bios_folder/mame-sa/samples" - create_dir "/var/data/mame/assets/artwork" - create_dir "/var/data/mame/assets/fonts" - create_dir "/var/data/mame/assets/crosshair" - create_dir "/var/data/mame/plugins" - create_dir "/var/data/mame/assets/language" - create_dir "/var/data/mame/assets/software" - create_dir "/var/data/mame/assets/comments" - create_dir "/var/data/mame/assets/share" - create_dir "/var/data/mame/dats" - create_dir "/var/data/mame/folders" - create_dir "/var/data/mame/assets/cabinets" - create_dir "/var/data/mame/assets/cpanel" - create_dir "/var/data/mame/assets/pcb" - create_dir "/var/data/mame/assets/flyers" - create_dir "/var/data/mame/assets/titles" - create_dir "/var/data/mame/assets/ends" - create_dir "/var/data/mame/assets/marquees" - create_dir "/var/data/mame/assets/artwork-preview" - create_dir "/var/data/mame/assets/bosses" - create_dir "/var/data/mame/assets/logo" - create_dir "/var/data/mame/assets/scores" - create_dir "/var/data/mame/assets/versus" - create_dir "/var/data/mame/assets/gameover" - create_dir "/var/data/mame/assets/howto" - create_dir "/var/data/mame/assets/select" - create_dir "/var/data/mame/assets/icons" - create_dir "/var/data/mame/assets/covers" - create_dir "/var/data/mame/assets/ui" + create_dir "$XDG_DATA_HOME/mame/assets/artwork" + create_dir "$XDG_DATA_HOME/mame/assets/fonts" + create_dir "$XDG_DATA_HOME/mame/assets/crosshair" + create_dir "$XDG_DATA_HOME/mame/plugins" + create_dir "$XDG_DATA_HOME/mame/assets/language" + create_dir "$XDG_DATA_HOME/mame/assets/software" + create_dir "$XDG_DATA_HOME/mame/assets/comments" + create_dir "$XDG_DATA_HOME/mame/assets/share" + create_dir "$XDG_DATA_HOME/mame/dats" + create_dir "$XDG_DATA_HOME/mame/folders" + create_dir "$XDG_DATA_HOME/mame/assets/cabinets" + create_dir "$XDG_DATA_HOME/mame/assets/cpanel" + create_dir "$XDG_DATA_HOME/mame/assets/pcb" + create_dir "$XDG_DATA_HOME/mame/assets/flyers" + create_dir "$XDG_DATA_HOME/mame/assets/titles" + create_dir "$XDG_DATA_HOME/mame/assets/ends" + create_dir "$XDG_DATA_HOME/mame/assets/marquees" + create_dir "$XDG_DATA_HOME/mame/assets/artwork-preview" + create_dir "$XDG_DATA_HOME/mame/assets/bosses" + create_dir "$XDG_DATA_HOME/mame/assets/logo" + create_dir "$XDG_DATA_HOME/mame/assets/scores" + create_dir "$XDG_DATA_HOME/mame/assets/versus" + create_dir "$XDG_DATA_HOME/mame/assets/gameover" + create_dir "$XDG_DATA_HOME/mame/assets/howto" + create_dir "$XDG_DATA_HOME/mame/assets/select" + create_dir "$XDG_DATA_HOME/mame/assets/icons" + create_dir "$XDG_DATA_HOME/mame/assets/covers" + create_dir "$XDG_DATA_HOME/mame/assets/ui" create_dir "$shaders_folder/mame/bgfx/" - dir_prep "$saves_folder/mame-sa/hiscore" "/var/config/mame/hiscore" + dir_prep "$saves_folder/mame-sa/hiscore" "$XDG_CONFIG_HOME/mame/hiscore" cp -fvr "$config/mame/mame.ini" "$mameconf" cp -fvr "$config/mame/ui.ini" "$mameuiconf" cp -fvr "$config/mame/default.cfg" "$mamedefconf" @@ -944,17 +944,17 @@ prepare_component() { log i "Prepearing GZDOOM" log i "----------------------" - create_dir "/var/config/gzdoom" - create_dir "/var/data/gzdoom/audio/midi" - create_dir "/var/data/gzdoom/audio/fm_banks" - create_dir "/var/data/gzdoom/audio/soundfonts" + create_dir "$XDG_CONFIG_HOME/gzdoom" + create_dir "$XDG_DATA_HOME/gzdoom/audio/midi" + create_dir "$XDG_DATA_HOME/gzdoom/audio/fm_banks" + create_dir "$XDG_DATA_HOME/gzdoom/audio/soundfonts" create_dir "$bios_folder/gzdoom" - cp -fvr "$config/gzdoom/gzdoom.ini" "/var/config/gzdoom" + cp -fvr "$config/gzdoom/gzdoom.ini" "$XDG_CONFIG_HOME/gzdoom" - sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON - sed -i 's#RETRODECKROMSDIR#'"$roms_folder"'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON - sed -i 's#RETRODECKSAVESDIR#'"$saves_folder"'#g' "/var/config/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKHOMEDIR#'"$rdhome"'#g' "$XDG_CONFIG_HOME/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKROMSDIR#'"$roms_folder"'#g' "$XDG_CONFIG_HOME/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON + sed -i 's#RETRODECKSAVESDIR#'"$saves_folder"'#g' "$XDG_CONFIG_HOME/gzdoom/gzdoom.ini" # This is an unfortunate one-off because set_setting_value does not currently support JSON fi if [[ "$component" =~ ^(portmaster|all)$ ]]; then @@ -964,14 +964,14 @@ prepare_component() { log i "Prepearing PortMaster" log i "----------------------" - rm -rf "/var/data/PortMaster" - unzip "/app/retrodeck/PortMaster.zip" -d "/var/data/" - cp -f "/var/data/PortMaster/retrodeck/PortMaster.txt" "/var/data/PortMaster/PortMaster.sh" - chmod +x "/var/data/PortMaster/PortMaster.sh" + rm -rf "$XDG_DATA_HOME/PortMaster" + unzip "/app/retrodeck/PortMaster.zip" -d "$XDG_DATA_HOME/" + cp -f "$XDG_DATA_HOME/PortMaster/retrodeck/PortMaster.txt" "$XDG_DATA_HOME/PortMaster/PortMaster.sh" + chmod +x "$XDG_DATA_HOME/PortMaster/PortMaster.sh" rm -f "$roms_folder/portmaster/PortMaster.sh" - install -Dm755 "/var/data/PortMaster/PortMaster.sh" "$roms_folder/portmaster/PortMaster.sh" - create_dir "/var/data/PortMaster/config/" - cp "$config/portmaster/config.json" "/var/data/PortMaster/config/config.json" + install -Dm755 "$XDG_DATA_HOME/PortMaster/PortMaster.sh" "$roms_folder/portmaster/PortMaster.sh" + create_dir "$XDG_DATA_HOME/PortMaster/config/" + cp "$config/portmaster/config.json" "$XDG_DATA_HOME/PortMaster/config/config.json" fi @@ -981,14 +981,14 @@ prepare_component() { log i "Prepearing Ruffle" log i "----------------------" - rm -rf "/var/config/ruffle" + rm -rf "$XDG_CONFIG_HOME/ruffle" # Ruffle creates a directory with the full rom paths in it, so this is necessary # TODO: be aware of this when multi user support will be integrated for this component - dir_prep "$saves_folder/flash" "/var/data/ruffle/SharedObjects/localhost/$roms_folder/flash" + dir_prep "$saves_folder/flash" "$XDG_DATA_HOME/ruffle/SharedObjects/localhost/$roms_folder/flash" if [[ "$action" == "postmove" ]]; then # Run only post-move commands - dir_prep "$saves_folder/flash" "/var/data/ruffle/SharedObjects/localhost/$roms_folder/flash" + dir_prep "$saves_folder/flash" "$XDG_DATA_HOME/ruffle/SharedObjects/localhost/$roms_folder/flash" fi fi diff --git a/functions/presets.sh b/functions/presets.sh index 39c2fd09..2358174e 100644 --- a/functions/presets.sh +++ b/functions/presets.sh @@ -114,14 +114,14 @@ build_preset_list_options() { preset="$1" pretty_preset_name=${preset//_/ } # Preset name prettification - pretty_preset_name=$(echo $pretty_preset_name | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification + pretty_preset_name=$(echo "$pretty_preset_name" | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification current_preset_settings=() current_enabled_systems=() current_disabled_systems=() changed_systems=() changed_presets=() all_systems=() - local section_results=$(sed -n '/\['"$preset"'\]/, /\[/{ /\['"$preset"'\]/! { /\[/! p } }' $rd_conf | sed '/^$/d') + local section_results=$(sed -n '/\['"$preset"'\]/, /\[/{ /\['"$preset"'\]/! { /\[/! p } }' "$rd_conf" | sed '/^$/d') while IFS= read -r config_line do @@ -133,8 +133,8 @@ build_preset_list_options() { elif [[ "$system_value" == "false" ]]; then current_disabled_systems=("${current_disabled_systems[@]}" "$system_name") fi - current_preset_settings=("${current_preset_settings[@]}" "$system_value" "$(make_name_pretty $system_name)" "$system_name") - echo "$system_value"^"$(make_name_pretty $system_name)"^"$system_name" >> "$godot_current_preset_settings" + current_preset_settings=("${current_preset_settings[@]}" "$system_value" "$(make_name_pretty "$system_name")" "$system_name") + echo "$system_value"^"$(make_name_pretty "$system_name")"^"$system_name" >> "$godot_current_preset_settings" done < <(printf '%s\n' "$section_results") } @@ -252,7 +252,7 @@ build_preset_config() { log d "Applying presets: $presets_being_changed for system: $system_being_changed" for current_preset in $presets_being_changed do - local preset_section=$(sed -n '/\['"$current_preset"'\]/, /\[/{ /\['"$current_preset"'\]/! { /\[/! p } }' $rd_conf | sed '/^$/d') + local preset_section=$(sed -n '/\['"$current_preset"'\]/, /\[/{ /\['"$current_preset"'\]/! { /\[/! p } }' "$rd_conf" | sed '/^$/d') while IFS= read -r system_line do local read_system_name=$(get_setting_name "$system_line") @@ -376,7 +376,7 @@ build_retrodeck_current_presets() { do if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$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 - local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name + local current_section=$(sed 's^[][]^^g' <<< "$current_setting_line") # Remove brackets from section name else if [[ ! ("$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" || "$current_section" == "cheevos" || "$current_section" == "cheevos_hardcore") ]]; then local system_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line @@ -387,7 +387,7 @@ build_retrodeck_current_presets() { fi fi fi - done < $rd_conf + done < "$rd_conf" } fetch_all_presets() { @@ -417,7 +417,7 @@ fetch_all_presets() { presets+=("$preset") if $pretty_output; then pretty_preset_name=${preset//_/ } # Preset name prettification - pretty_preset_name=$(echo $pretty_preset_name | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification + pretty_preset_name=$(echo "$pretty_preset_name" | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification pretty_presets+=("$pretty_preset_name") fi fi @@ -433,7 +433,7 @@ fetch_all_presets() { presets+=("$preset") if $pretty_output; then pretty_preset_name=${preset//_/ } # Preset name prettification - pretty_preset_name=$(echo $pretty_preset_name | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification + pretty_preset_name=$(echo "$pretty_preset_name" | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification pretty_presets+=("$pretty_preset_name") fi fi diff --git a/functions/run_game.sh b/functions/run_game.sh index ca08103b..3b3be46f 100755 --- a/functions/run_game.sh +++ b/functions/run_game.sh @@ -389,8 +389,8 @@ find_emulator() { while IFS= read -r line; do command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') # Check if the command specified by the variable 'command_path' exists and is executable - if [ -x "$(command -v $command_path)" ]; then - found_path=$command_path + if [ -x "$(command -v "$command_path")" ]; then + found_path="$command_path" break fi done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='systempath']/entry" - 2>/dev/null)" @@ -400,7 +400,7 @@ find_emulator() { while IFS= read -r line; do command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') if [ -x "$command_path" ]; then - found_path=$command_path + found_path="$command_path" break fi done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='staticpath']/entry" - 2>/dev/null)" @@ -466,4 +466,4 @@ find_system_by_extension() { # Return the detected system echo "$detected_system" -} \ No newline at end of file +} diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index 75a89af6..8a15a1d6 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -9,7 +9,7 @@ steam_sync() { # USAGE: steam_sync log "i" "Starting Steam Sync" - create_dir $steamsync_folder + create_dir "$steamsync_folder" if [ ! -f "$srm_path" ]; then log "e" "Steam ROM Manager configuration not initialized! Initializing now." From ea673bbda41962b9d95a670857fa838514d9715b Mon Sep 17 00:00:00 2001 From: icenine451 Date: Fri, 28 Mar 2025 16:27:29 -0400 Subject: [PATCH 13/15] Fix Portmaster Zenity Configurator menu flow --- tools/configurator.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/configurator.sh b/tools/configurator.sh index d18ce707..e7da3b12 100755 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -980,7 +980,7 @@ configurator_portmaster_toggle_dialog(){ --title "RetroDECK Configurator - PortMaster Visibility" \ --text="PortMaster is now hidden in ES-DE.\nPlease refresh your game list or restart RetroDECK to see the changes.\n\nIn order to launch PortMaster, you can access it from:\nConfigurator -> Open Component -> PortMaster." else # User clicked "Cancel" - configurator_tools_dialog + configurator_global_presets_and_settings_dialog fi else rd_zenity --question \ @@ -996,10 +996,10 @@ configurator_portmaster_toggle_dialog(){ --title "RetroDECK Configurator - PortMaster Visibility" \ --text="PortMaster is now visible in ES-DE.\nPlease refresh your game list or restart RetroDECK to see the changes." else # User clicked "Cancel" - configurator_tools_dialog + configurator_global_presets_and_settings_dialog fi fi - configurator_tools_dialog + configurator_global_presets_and_settings_dialog } # This function checks and verifies BIOS files for RetroDECK. From 69e1fe868de3f5221384070f365c6eecc06d81cc Mon Sep 17 00:00:00 2001 From: icenine451 Date: Fri, 28 Mar 2025 16:40:08 -0400 Subject: [PATCH 14/15] Add Zenity Configurator menu to change logging level --- tools/configurator.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/configurator.sh b/tools/configurator.sh index e7da3b12..8c888b4b 100755 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -77,6 +77,7 @@ rd_zenity --progress --no-cancel --pulsate --auto-close \ # - Add RetroDECK to Steam # - M3U Multi-File Validator # - Repair RetroDECK paths +# - Change logging level # - Ponzu: Remove Yuzu # - Ponzu: Remove Citra # - Steam Sync @@ -444,6 +445,7 @@ configurator_tools_dialog() { "Add RetroDECK to Steam" "Add RetroDECK shortcut to Steam. Steam restart required." "M3U Multi-File Validator" "Verify the proper structure of multi-file or multi-disc games." "Repair RetroDECK Paths" "Repair RetroDECK folder path configs for unexpectedly missing folders." + "Change Logging Level" "Change the RetroDECK logging level, for debugging purposes" ) if [[ $(get_setting_value "$rd_conf" "kiroi_ponzu" "retrodeck" "options") == "true" ]]; then @@ -608,6 +610,46 @@ configurator_tools_dialog() { configurator_tools_dialog ;; + "Change Logging Level" ) + log i "Configurator: opening \"$choice\" menu" + choice=$(rd_zenity --list --title="RetroDECK Configurator Utility - RetroDECK: Change Logging Level" --cancel-label="Back" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ + --column="Choice" --column="Action" \ + "Informational" "The default, only logs important information." \ + "Warnings" "Additionally log warnings." \ + "Errors" "Additionally log warnings and errors." \ + "Debug" "Log everything, may generate a lot of logs!." \) + + case $choice in + + "Informational" ) + log i "Configurator: Changing logging level to \"$choice\"" + set_setting_value "$rd_conf" "logging_level" "info" "retrodeck" "options" + ;; + + "Warnings" ) + log i "Configurator: Changing logging level to \"$choice\"" + set_setting_value "$rd_conf" "logging_level" "warn" "retrodeck" "options" + ;; + + "Errors" ) + log i "Configurator: Changing logging level to \"$choice\"" + set_setting_value "$rd_conf" "logging_level" "error" "retrodeck" "options" + ;; + + "Debug" ) + log i "Configurator: Changing logging level to \"$choice\"" + set_setting_value "$rd_conf" "logging_level" "debug" "retrodeck" "options" + ;; + + "" ) # No selection made or Back button clicked + log i "Configurator: going back" + ;; + + esac + configurator_tools_dialog + ;; + "Ponzu: Remove Yuzu" ) ponzu_remove "yuzu" ;; From 83bd6ee3843252628b5b4516977fc7be01981379 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Fri, 28 Mar 2025 17:10:46 -0400 Subject: [PATCH 15/15] Exclude .png and .po from the exported RetroDECK MIME types --- developer_toolbox/mime-populator.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/developer_toolbox/mime-populator.sh b/developer_toolbox/mime-populator.sh index 04a14ed8..ac6b5ec9 100755 --- a/developer_toolbox/mime-populator.sh +++ b/developer_toolbox/mime-populator.sh @@ -4,7 +4,7 @@ ES_SYSTEMS_FILE="../ES-DE/resources/systems/linux/es_systems.xml" MIME_FILE="config/retrodeck/net.retrodeck.retrodeck.mime.xml" # List of extensions to ignore -IGNORED_EXTENSIONS=". .appimage cue" +IGNORED_EXTENSIONS=". .appimage cue png po" # Check if xmlstarlet is installed if ! command -v xmlstarlet &> /dev/null; then @@ -53,4 +53,4 @@ xmlstarlet fo --indent-tab "$MIME_FILE" > "$MIME_FILE.tmp" && mv "$MIME_FILE.tmp # Clean up temporary files rm -f "$EXTENSIONS_FILE" -echo "MIME file updated successfully at $MIME_FILE" \ No newline at end of file +echo "MIME file updated successfully at $MIME_FILE"