Create file only if does not exists + fixed syntax

This commit is contained in:
Lx32 2024-09-24 21:53:52 +02:00
parent ec1f9a0305
commit 4c2e555812
2 changed files with 13 additions and 7 deletions

View file

@ -907,4 +907,4 @@ start_retrodeck() {
ponzu ponzu
log i "Starting RetroDECK v$version" log i "Starting RetroDECK v$version"
es-de es-de
} }

View file

@ -76,7 +76,10 @@ add_to_steam() {
log d "Sanitized Name: $sanitized_name" log d "Sanitized Name: $sanitized_name"
local launcher="$steamsync_folder/${sanitized_name}.sh" 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 # if [[ -v command_list_default[$system] ]]; then
# command="${command_list_default[$system]}" # command="${command_list_default[$system]}"
@ -88,7 +91,7 @@ add_to_steam() {
# Populate the .sync script with the correct command # 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 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 # 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) # 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 <<EOF > "$launcher" # cat <<EOF > "$launcher"
# [Desktop Entry] # [Desktop Entry]
@ -101,21 +104,24 @@ add_to_steam() {
# Type=Application # Type=Application
# Categories=Game;Emulator; # Categories=Game;Emulator;
# EOF # EOF
cat <<EOF > "$launcher" cat <<EOF > "$launcher"
#!/bin/bash #!/bin/bash
if [ test "$(whereis flatpak)" = "flatpak:" ]; then if [ test "\$(whereis flatpak)" = "flatpak:" ]; then
flatpak-spawn --host $command flatpak-spawn --host $command
else else
$command $command
fi fi
EOF EOF
else
log d "$launcher desktop file already exists"
fi
done done
fi fi
done done
steam-rom-manager add #steam-rom-manager add
log i "Steam Sync: completed" log i "Steam Sync: completed"
} }
remove_from_steam() { remove_from_steam() {
echo "TBD" echo "TBD"
} }