mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-04-10 19:15:12 +00:00
Reduce code duplication in steam_sync
This commit is contained in:
parent
6d7e8beb93
commit
9768a82d09
|
|
@ -85,20 +85,7 @@ steam_sync() {
|
||||||
if [[ -f "$retrodeck_favorites_file" ]]; then # If an existing favorites manifest exists
|
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
|
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"
|
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
|
steam_sync_remove
|
||||||
) |
|
|
||||||
rd_zenity --progress \
|
|
||||||
--title="Syncing with Steam" \
|
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
|
||||||
--text="<span foreground='$purple'><b>\t\t\t\tRemoving unfavorited games from Steam</b></span>\n\n<b>NOTE: </b>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
|
# Old manifest cleanup
|
||||||
rm "$retrodeck_favorites_file"
|
rm "$retrodeck_favorites_file"
|
||||||
rm "${retrodeck_favorites_file}.new"
|
rm "${retrodeck_favorites_file}.new"
|
||||||
|
|
@ -112,35 +99,13 @@ steam_sync() {
|
||||||
log d "Some favorites removed between syncs, removing unfavorited games"
|
log d "Some favorites removed between syncs, removing unfavorited games"
|
||||||
# Load removed favorites as manifest and run SRM remove
|
# Load removed favorites as manifest and run SRM remove
|
||||||
mv "$retrodeck_removed_favorites" "$retrodeck_favorites_file"
|
mv "$retrodeck_removed_favorites" "$retrodeck_favorites_file"
|
||||||
if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then
|
|
||||||
(
|
|
||||||
steam_sync_remove
|
steam_sync_remove
|
||||||
) |
|
|
||||||
rd_zenity --progress \
|
|
||||||
--title="Syncing with Steam" \
|
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
|
||||||
--text="<span foreground='$purple'><b>\t\t\t\tRemoving unfavorited games from Steam</b></span>\n\n<b>NOTE: </b>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
|
fi
|
||||||
if [[ -f "$retrodeck_added_favorites" ]]; then # If some new favorites were added between syncs
|
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"
|
log d "Some new favorites added between syncs, adding new favorited games"
|
||||||
# Load added favorites as manifest and run SRM add
|
# Load added favorites as manifest and run SRM add
|
||||||
mv "$retrodeck_added_favorites" "$retrodeck_favorites_file"
|
mv "$retrodeck_added_favorites" "$retrodeck_favorites_file"
|
||||||
if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then
|
|
||||||
(
|
|
||||||
steam_sync_add
|
steam_sync_add
|
||||||
) |
|
|
||||||
rd_zenity --progress \
|
|
||||||
--title="Syncing with Steam" \
|
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
|
||||||
--text="<span foreground='$purple'><b>\t\t\t\tAdding new favorited games to Steam</b></span>\n\n<b>NOTE: </b>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
|
fi
|
||||||
|
|
||||||
# Make new favorites manifest the current one
|
# Make new favorites manifest the current one
|
||||||
|
|
@ -150,31 +115,44 @@ steam_sync() {
|
||||||
elif [[ "$(cat "${retrodeck_favorites_file}.new" | jq 'length')" -gt 0 ]]; then # No existing favorites manifest was found, so check if new manifest has entries
|
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"
|
log d "First time building favorites manifest, running sync"
|
||||||
mv "${retrodeck_favorites_file}.new" "$retrodeck_favorites_file"
|
mv "${retrodeck_favorites_file}.new" "$retrodeck_favorites_file"
|
||||||
if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then
|
|
||||||
(
|
|
||||||
# Add new favorites manifest
|
|
||||||
steam_sync_add
|
steam_sync_add
|
||||||
) |
|
|
||||||
rd_zenity --progress \
|
|
||||||
--title="Syncing with Steam" \
|
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
|
||||||
--text="<span foreground='$purple'><b>\t\t\t\tSyncing favorite games with Steam</b></span>\n\n<b>NOTE: </b>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
|
||||||
}
|
}
|
||||||
|
|
||||||
steam_sync_add() {
|
steam_sync_add() {
|
||||||
|
if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then
|
||||||
|
(
|
||||||
steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1
|
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 enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1
|
||||||
steam-rom-manager add >> "$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="<span foreground='$purple'><b>\t\t\t\tAdding new favorited games to Steam</b></span>\n\n<b>NOTE: </b>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() {
|
steam_sync_remove() {
|
||||||
|
if [[ "$CONFIGURATOR_GUI" == "zenity" ]]; then
|
||||||
|
(
|
||||||
steam-rom-manager disable --names "RetroDECK Launcher" >> "$srm_log" 2>&1
|
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 enable --names "RetroDECK Steam Sync" >> "$srm_log" 2>&1
|
||||||
steam-rom-manager remove >> "$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="<span foreground='$purple'><b>\t\t\t\tRemoving unfavorited games from Steam</b></span>\n\n<b>NOTE: </b>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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue