diff --git a/darwin/tools/launchers/retroarch.sh b/darwin/tools/launchers/retroarch.sh index e87d30aa..e7bf44b8 100755 --- a/darwin/tools/launchers/retroarch.sh +++ b/darwin/tools/launchers/retroarch.sh @@ -1,5 +1,5 @@ #!/bin/bash #source $HOME/.config/EmuDeck/backend/functions/all.sh -#cloud_sync_downloadEmu "retroarch" && cloud_sync_startService +#emulatorInit "retroarch" open "$HOME/Applications/EmuDeck/RetroArch.app" --args "${@}" #rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/functions/helperFunctions.sh b/functions/helperFunctions.sh index 81c26b15..f56d0407 100644 --- a/functions/helperFunctions.sh +++ b/functions/helperFunctions.sh @@ -774,3 +774,140 @@ scriptConfigFileGetVar() { printf -- "%s" "${configVarValue}" } + + +getEmuRepo() { + case "$1" in + "cemu") repo="cemu-project/Cemu" ;; + "citra") repo="citra-emu/citra-nightly" ;; + "dolphin") repo="shiiion/dolphin" ;; + "duckstation") repo="stenzek/duckstation" ;; + "flycast") repo="flyinghead/flycast" ;; + "MAME") repo="mamedev/mame" ;; + "melonDS") repo="melonDS-emu/melonDS" ;; + "mgba") repo="mgba-emu/mgba" ;; + "pcsx2") repo="pcsx2/pcsx2" ;; + "primehack") repo="shiiion/dolphin" ;; + "rpcs3") repo="RPCS3/rpcs3-binaries-win" ;; + "ryujinx") repo="Ryujinx/release-channel-master" ;; + "vita3K") repo="Vita3K/Vita3K" ;; + "xemu") repo="xemu-project/xemu" ;; + "xenia") repo="xenia-canary/xenia-canary" ;; + "yuzu") repo="yuzu-emu/yuzu-mainline" ;; + *) repo="none" ;; + esac + echo "$repo" +} + +getLatestVersionGH() { + repository=$1 + url="https://api.github.com/repos/$repository/releases/latest" + id=$(curl -s $url | jq -r '.id') + echo $id +} + +#!/bin/bash + +saveLatestVersionGH() { + emuName=$1 + repo=$(getEmuRepo "$emuName") + + if [ "$repo" == "none" ]; then + echo "no autoupdate" + else + emuVersion=$(getLatestVersionGH "$repo") + + # JSON file path + jsonFilePath="$HOME/EmuDeck/emu_versions.json" + + if [ -e "$jsonFilePath" ]; then + echo "file found" + else + echo "{}" > "$jsonFilePath" + fi + + # Read the content of the JSON file + jsonContent=$(cat "$jsonFilePath" | jq -c '.') + + # Check if the key exists + if [[ $(echo "$jsonContent" | jq -r ".$emuName") != "null" ]]; then + # The key exists, change its value + jsonContent=$(echo "$jsonContent" | jq ".$emuName=\"$emuVersion\"") + else + # The key doesn't exist, create it with a new value + jsonContent=$(echo "$jsonContent" | jq ".$emuName=\"$emuVersion\"") + fi + + # Save the modified JSON back to the file + echo "$jsonContent" > "$jsonFilePath" + fi +} + +#!/bin/bash + +isLatestVersionGH() { + emuName=$1 + + if [ "$(check_internet_connection)" == "true" ]; then + repo=$(getEmuRepo "$emuName") + + if [ "$repo" == "none" ]; then + echo "no autoupdate" + else + emuVersion=$(getLatestVersionGH "$repo") + + # JSON file path + jsonFilePath="$HOME/EmuDeck/emu_versions.json" + + if [ -e "$jsonFilePath" ]; then + echo "file found" + else + echo "{}" > "$jsonFilePath" + fi + + # Read the content of the JSON file + jsonContent=$(cat "$jsonFilePath" | jq -c '.') + + # Check if the key exists + if [[ $(echo "$jsonContent" | jq -r ".$emuName") != "null" ]]; then + # The key exists, check if it's the same value + if [ "$(echo "$jsonContent" | jq -r ".$emuName")" != "$emuVersion" ]; then + jsonContent=$(echo "$jsonContent" | jq ".$emuName=\"$emuVersion\"") + latest="false" + else + latest="true" + fi + else + # The key doesn't exist, create it with a new value + jsonContent=$(echo "$jsonContent" | jq ".$emuName=\"$emuVersion\"") + latest="true" + fi + + if [ "$latest" == "false" ]; then + # Ask the user to update + capitalizedEmuName="$(echo $emuName | awk '{print toupper(substr($1,1,1))tolower(substr($1,2))}')" + zenity --question --title "New Update" --text "We've detected an update for $capitalizedEmuName. Do you want to update?" --ok-label "Yes" --cancel-label "No" + if [ $? = 0 ]; then + # Save the modified JSON back to the file + echo "$jsonContent" > "$jsonFilePath" + + # Invocar la función de instalación dinámicamente + "${capitalizedEmuName}_install" + fi + else + # Save the modified JSON back to the file + echo "$jsonContent" > "$jsonFilePath" + fi + + echo "Latest version=$latest" + fi + fi +} + + +function emulatorInit($emuName){ + isLatestVersionGH($emuName) + cloud_sync_downloadEmu $emuName && cloud_sync_startService +} + + diff --git a/tools/launchers/ares-emu.sh b/tools/launchers/ares-emu.sh index c92f606b..b24f387b 100755 --- a/tools/launchers/ares-emu.sh +++ b/tools/launchers/ares-emu.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "ares" && cloud_sync_startService +emulatorInit "ares" /usr/bin/flatpak run dev.ares.ares "${@}" rm -rf "$savesPath/.gaming" diff --git a/tools/launchers/cemu-native.sh b/tools/launchers/cemu-native.sh index 0c6eb724..1871f649 100644 --- a/tools/launchers/cemu-native.sh +++ b/tools/launchers/cemu-native.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "cemu-native" && cloud_sync_startService +emulatorInit "cemu-native" # shellcheck disable=SC1091 . "${HOME}/emudeck/settings.sh" diff --git a/tools/launchers/cemu.sh b/tools/launchers/cemu.sh index 91c3a640..b92296e0 100755 --- a/tools/launchers/cemu.sh +++ b/tools/launchers/cemu.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "Cemu" && cloud_sync_startService +emulatorInit "Cemu" # cemu.sh # Report Errors diff --git a/tools/launchers/citra.sh b/tools/launchers/citra.sh index dbdb824c..e8d07493 100644 --- a/tools/launchers/citra.sh +++ b/tools/launchers/citra.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "citra" && cloud_sync_startService +emulatorInit "citra" /usr/bin/flatpak run org.citra_emu.citra "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/dolphin-emu.sh b/tools/launchers/dolphin-emu.sh index c551b5cf..5898bb1d 100644 --- a/tools/launchers/dolphin-emu.sh +++ b/tools/launchers/dolphin-emu.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "dolphin" && cloud_sync_startService +emulatorInit "dolphin" /usr/bin/flatpak run org.DolphinEmu.dolphin-emu "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/duckstation.sh b/tools/launchers/duckstation.sh index dffb52ef..167ce7c9 100644 --- a/tools/launchers/duckstation.sh +++ b/tools/launchers/duckstation.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "duckstation" && cloud_sync_startService +emulatorInit "duckstation" /usr/bin/flatpak run org.duckstation.DuckStation "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/flycast.sh b/tools/launchers/flycast.sh index 069b3cee..c4703e7b 100644 --- a/tools/launchers/flycast.sh +++ b/tools/launchers/flycast.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "flycast" && cloud_sync_startService +emulatorInit "flycast" /usr/bin/flatpak run org.flycast.Flycast "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/mame.sh b/tools/launchers/mame.sh index b99739b8..c319de00 100755 --- a/tools/launchers/mame.sh +++ b/tools/launchers/mame.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "mame" && cloud_sync_startService +emulatorInit "mame" /usr/bin/flatpak run org.mamedev.MAME "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/melonds.sh b/tools/launchers/melonds.sh index 8cf2e774..a18dd385 100644 --- a/tools/launchers/melonds.sh +++ b/tools/launchers/melonds.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "melonds" && cloud_sync_startService +emulatorInit "melonds" /usr/bin/flatpak run net.kuribo64.melonDS "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/mgba.sh b/tools/launchers/mgba.sh index 2443429c..85f14553 100755 --- a/tools/launchers/mgba.sh +++ b/tools/launchers/mgba.sh @@ -1,6 +1,6 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "mgba" && cloud_sync_startService +emulatorInit "mgba" emuName="mGBA" #parameterize me emufolder="$HOME/Applications" # has to be applications for ES-DE to find it diff --git a/tools/launchers/pcsx2-qt.sh b/tools/launchers/pcsx2-qt.sh index 94766726..ff3eb442 100755 --- a/tools/launchers/pcsx2-qt.sh +++ b/tools/launchers/pcsx2-qt.sh @@ -1,6 +1,6 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu pcsx2 && cloud_sync_startService +emulatorInit "pcsx2" emuName="pcsx2-Qt" #parameterize me emufolder="$HOME/Applications" # has to be applications for ES-DE to find it diff --git a/tools/launchers/ppsspp.sh b/tools/launchers/ppsspp.sh index ce9983da..994ab392 100755 --- a/tools/launchers/ppsspp.sh +++ b/tools/launchers/ppsspp.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "ppsspp" && cloud_sync_startService +emulatorInit "ppsspp" /usr/bin/flatpak run org.ppsspp.PPSSPP "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/primehack.sh b/tools/launchers/primehack.sh index c50c7c9c..f10fb7d4 100644 --- a/tools/launchers/primehack.sh +++ b/tools/launchers/primehack.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "primehack" && cloud_sync_startService +emulatorInit "primehack" /usr/bin/flatpak run io.github.shiiion.primehack "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/retroarch.sh b/tools/launchers/retroarch.sh index 15493cae..a0a181e9 100644 --- a/tools/launchers/retroarch.sh +++ b/tools/launchers/retroarch.sh @@ -1,5 +1,5 @@ #!/bin/bash source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "retroarch" && cloud_sync_startService +emulatorInit "retroarch" /usr/bin/flatpak run org.libretro.RetroArch "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/rosaliesmupengui.sh b/tools/launchers/rosaliesmupengui.sh index 93fba4fd..7da53176 100755 --- a/tools/launchers/rosaliesmupengui.sh +++ b/tools/launchers/rosaliesmupengui.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "RMG" && cloud_sync_startService +emulatorInit "RMG" /usr/bin/flatpak run com.github.Rosalie241.RMG "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/rpcs3.sh b/tools/launchers/rpcs3.sh index b43106d8..8b43ffbe 100644 --- a/tools/launchers/rpcs3.sh +++ b/tools/launchers/rpcs3.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "rpcs3" && cloud_sync_startService +emulatorInit "rpcs3" /usr/bin/flatpak run net.rpcs3.RPCS3 "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/ryujinx.sh b/tools/launchers/ryujinx.sh index c4406227..3d1f9117 100755 --- a/tools/launchers/ryujinx.sh +++ b/tools/launchers/ryujinx.sh @@ -1,6 +1,6 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "ryujinx" && cloud_sync_startService +emulatorInit "ryujinx" emuName="Ryujinx.sh" #parameterize me emufolder="$HOME/Applications/publish" # has to be applications for ES-DE to find it diff --git a/tools/launchers/scummvm.sh b/tools/launchers/scummvm.sh index c05c4f90..85d6f5a3 100644 --- a/tools/launchers/scummvm.sh +++ b/tools/launchers/scummvm.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "scummvm" && cloud_sync_startService +emulatorInit "scummvm" /usr/bin/flatpak run org.scummvm.ScummVM "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/vita3k.sh b/tools/launchers/vita3k.sh index 975fdc7c..95247264 100755 --- a/tools/launchers/vita3k.sh +++ b/tools/launchers/vita3k.sh @@ -1,6 +1,6 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "Vita3k" && cloud_sync_startService +emulatorInit "Vita3k" export LC_ALL="C" emuName="Vita3K" #parameterize me diff --git a/tools/launchers/xemu-emu.sh b/tools/launchers/xemu-emu.sh index 8fbc25b8..b01ef729 100644 --- a/tools/launchers/xemu-emu.sh +++ b/tools/launchers/xemu-emu.sh @@ -1,5 +1,5 @@ #!/bin/sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "xemu" && cloud_sync_startService +emulatorInit "xemu" /usr/bin/flatpak run app.xemu.xemu "${@}" rm -rf "$savesPath/.gaming" \ No newline at end of file diff --git a/tools/launchers/xenia.sh b/tools/launchers/xenia.sh index 8392ab0f..d96f30ab 100644 --- a/tools/launchers/xenia.sh +++ b/tools/launchers/xenia.sh @@ -1,7 +1,7 @@ #!/usr/bin/bash # xenia.sh source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "xenia" && cloud_sync_startService +emulatorInit "xenia" # Get SELFPATH SELFPATH="$( realpath "${BASH_SOURCE[0]}" )" diff --git a/tools/launchers/yuzu.sh b/tools/launchers/yuzu.sh index da3f4a89..cd587460 100755 --- a/tools/launchers/yuzu.sh +++ b/tools/launchers/yuzu.sh @@ -1,6 +1,6 @@ #!/bin/bash source $HOME/.config/EmuDeck/backend/functions/all.sh -cloud_sync_downloadEmu "yuzu" && cloud_sync_startService +emulatorInit "yuzu" emuName="yuzu" #parameterize me useEAifFound="true" # set to false to simply use the newest file found