From 4c2e5558127b3236218371d733d5309f17e69109 Mon Sep 17 00:00:00 2001 From: Lx32 Date: Tue, 24 Sep 2024 21:53:52 +0200 Subject: [PATCH 1/4] Create file only if does not exists + fixed syntax --- functions/other_functions.sh | 2 +- functions/steam_sync.sh | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 1161ba58..99b6f05d 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -907,4 +907,4 @@ start_retrodeck() { ponzu log i "Starting RetroDECK v$version" es-de -} \ No newline at end of file +} diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index c7df8e02..b9138e66 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -76,7 +76,10 @@ add_to_steam() { log d "Sanitized Name: $sanitized_name" local launcher="$steamsync_folder/${sanitized_name}.sh" - log d "Creating desktop file: $launcher" + + if [ ! -e $launcher ]; then + + log d "Creating desktop file: $launcher" # if [[ -v command_list_default[$system] ]]; then # command="${command_list_default[$system]}" @@ -88,7 +91,7 @@ add_to_steam() { # Populate the .sync script with the correct command # TODO: if there is any emulator defined in the xml we use that, else... how we can know which is the default one? # TODO: if steam is flatpak the command wrapping will change in .desktop - local command="flatpak run net.retrodeck.retrodeck start '$roms_folder/$system/$path'" + local command="flatpak run net.retrodeck.retrodeck start '$roms_folder/$system/$path'" # Create the launcher file using a heredoc - if you enable .desktp this remember to edit .desktop in SRM userConfigurations.json and the above launcher variable (and vice versa) # cat < "$launcher" # [Desktop Entry] @@ -101,21 +104,24 @@ add_to_steam() { # Type=Application # Categories=Game;Emulator; # EOF - cat < "$launcher" + cat < "$launcher" #!/bin/bash -if [ test "$(whereis flatpak)" = "flatpak:" ]; then +if [ test "\$(whereis flatpak)" = "flatpak:" ]; then flatpak-spawn --host $command else $command fi EOF + else + log d "$launcher desktop file already exists" + fi done fi done - steam-rom-manager add + #steam-rom-manager add log i "Steam Sync: completed" } remove_from_steam() { echo "TBD" -} \ No newline at end of file +} From f456fbbda711249bd0ffe15e5a78efab5f6ae77c Mon Sep 17 00:00:00 2001 From: Lx32 Date: Tue, 24 Sep 2024 22:06:53 +0200 Subject: [PATCH 2/4] Added full shortcut clean --- functions/steam_sync.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index b9138e66..6f8c9037 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -118,10 +118,23 @@ EOF done fi done - #steam-rom-manager add + + if [ -z "$( ls -A $steamsync_folder )" ]; then + log d "No games found, cleaning shortcut" + remove_from_steam + else + log d "Updating game list" + #steam-rom-manager add + fi + log i "Steam Sync: completed" } remove_from_steam() { - echo "TBD" + log d "Creating fake game" + cat "" > "$steamsync_folder/CUL0.sh" + log d "Cleaning the shortcut" + steam-rom-manager remove + log d "Removing fake game" + rm "$steamsync_folder/CUL0.sh" } From 821fda1c47e8ac7e74077891f7020c25f6e41663 Mon Sep 17 00:00:00 2001 From: Lx32 Date: Tue, 24 Sep 2024 22:27:04 +0200 Subject: [PATCH 3/4] Fixed check if file exists --- functions/steam_sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index 6f8c9037..b52dbe2b 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -77,7 +77,7 @@ add_to_steam() { local launcher="$steamsync_folder/${sanitized_name}.sh" - if [ ! -e $launcher ]; then + if [ ! -e "$launcher" ]; then log d "Creating desktop file: $launcher" From c948f88f19b5ffc69501941d1cdec8cde1730813 Mon Sep 17 00:00:00 2001 From: Lx32 Date: Tue, 24 Sep 2024 22:33:20 +0200 Subject: [PATCH 4/4] Added remove no fav game --- functions/steam_sync.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions/steam_sync.sh b/functions/steam_sync.sh index b52dbe2b..84f85d16 100644 --- a/functions/steam_sync.sh +++ b/functions/steam_sync.sh @@ -6,6 +6,9 @@ add_to_steam() { log "i" "Starting Steam Sync" steamsync_folder="$rdhome/.sync" + steamsync_folder_tmp="$rdhome/.sync-tmp" + create_dir $steamsync_folder + mv $steamsync_folder $steamsync_folder_tmp create_dir $steamsync_folder local srm_path="/var/config/steam-rom-manager/userData/userConfigurations.json" @@ -76,8 +79,9 @@ add_to_steam() { log d "Sanitized Name: $sanitized_name" local launcher="$steamsync_folder/${sanitized_name}.sh" + local launcher_tmp="$steamsync_folder_tmp/${sanitized_name}.sh" - if [ ! -e "$launcher" ]; then + if [ ! -e "$launcher_tmp" ]; then log d "Creating desktop file: $launcher" @@ -114,11 +118,14 @@ fi EOF else log d "$launcher desktop file already exists" + mv "$launcher_tmp" "$launcher" fi done fi done + rm -r $steamsync_folder_tmp + if [ -z "$( ls -A $steamsync_folder )" ]; then log d "No games found, cleaning shortcut" remove_from_steam