emulatorInit + Autoupdate

This commit is contained in:
Dragoon Dorise 2024-01-05 11:43:43 +01:00
parent 83b79f19ac
commit 63a39d733f
24 changed files with 160 additions and 23 deletions

View file

@ -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"

View file

@ -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
}

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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]}" )"

View file

@ -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