yuzu-EA improvements (#628)

* Update yuzu.sh

- perform update check only if launching mainline release
-

* yuzu-EA qol improvements

- update shortcut + icon if using EA
- download EA metadata only once
- use .temp file to download EA, rename and chmod +x it after download
- do not start update if EA metadata is missing for some reason
- added YuzuEA_uninstall()
+ set yuzu.ver in Yuzu_install() so that yuzu.sh updater doesn't ask for update

* Update emuDeckYuzu.sh

- moved yuzu-ea.AppImage check outside tokenFile check (launcher would still find yuzu-ea)
This commit is contained in:
Mitja Skuver 2023-02-23 06:06:22 +01:00 committed by GitHub
parent 6c98130814
commit 2fb5e355e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 40 deletions

View file

@ -18,7 +18,12 @@ Yuzu_cleanup(){
#Install
Yuzu_install(){
echo "Begin Yuzu Install"
local lastDL="$HOME/emudeck/yuzu.ver"
local latestVer=$(curl -fSs "https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases" | jq -r '[ .[].tag_name ][0]')
installEmuAI "yuzu" "$(getReleaseURLGH "yuzu-emu/yuzu-mainline" "AppImage")" #needs to be lowercase yuzu for EsDE to find it.
echo $latestVer > $lastDL
YuzuEA_install # call the EA install. If the user has the token in the right spot, it will download EA as well for them.
}
@ -26,17 +31,22 @@ YuzuEA_install(){
local jwtHost="https://api.yuzu-emu.org/jwt/installer/"
local yuzuEaHost="https://api.yuzu-emu.org/downloads/earlyaccess/"
local fileToDownload=$(curl ${yuzuEaHost} | jq -r '.files[] | select(.name|test(".*.AppImage")).url')
local currentVer=$(curl ${yuzuEaHost} | jq -r '.files[] | select(.name|test(".*.AppImage")).name')
local yuzuEaMetadata=$(curl -fSs ${yuzuEaHost})
local fileToDownload=$(echo $yuzuEaMetadata | jq -r '.files[] | select(.name|test(".*.AppImage")).url')
local currentVer=$(echo $yuzuEaMetadata | jq -r '.files[] | select(.name|test(".*.AppImage")).name')
local tokenFile="$HOME/emudeck/yuzu-ea-token.txt"
local lastDL="$HOME/emudeck/yuzu-ea.ver"
if [ -e "$tokenFile" ]; then
if [ "$currentVer" == "$(cat ${lastDL})" ] ;then
if [ "$currentVer" == "$(cat ${lastDL})" ]; then
echo "no need to update."
elif [ -z $currentVer ]; then
echo "couldn't get metadata."
else
echo "updating"
@ -48,12 +58,13 @@ if [ -e "$tokenFile" ]; then
BEARERTOKEN=$(curl -X POST ${jwtHost} -H "X-Username: ${user}" -H "X-Token: ${auth}" -H "User-Agent: EmuDeck")
echo "download ea appimage"
response=$(curl -f -X GET ${fileToDownload} --write-out '%{http_code}' -H "Accept: application/json" -H "Authorization: Bearer ${BEARERTOKEN}" -o "${HOME}/Applications/yuzu-ea.AppImage")
response=$(curl -f -X GET ${fileToDownload} --write-out '%{http_code}' -H "Accept: application/json" -H "Authorization: Bearer ${BEARERTOKEN}" -o "${YuzuEA_emuPath}.temp")
if [ "$response" = "200" ] ; then
if [ "$response" = "200" ]; then
echo "EA downloaded successfully"
mv -v "$YuzuEA_emuPath.temp" "$YuzuEA_emuPath" && chmod +x "$YuzuEA_emuPath"
echo ${currentVer} > ${lastDL}
elif [ "$response" = "401" ] ; then
elif [ "$response" = "401" ]; then
echo "Not authorized. Check your patreon status."
else
echo "EA Download errored with code $response"
@ -66,12 +77,21 @@ if [ -e "$tokenFile" ]; then
fi
fi
else
echo "Token Not Found"
fi
# if we have yuzu-ea.AppImage, launcher will use that instead of mainline one so we can decorate shortcut
if [ -e "$YuzuEA_emuPath" ]; then
yuzuShortcut="$HOME/.local/share/applications/yuzu.desktop"
if [ -e "$yuzuShortcut" ]; then
desktopShortcutFieldUpdate "$yuzuShortcut" "Name" "yuzu-EA AppImage"
fi
fi
}
#ApplyInitialSettings
@ -181,8 +201,13 @@ Yuzu_wipe(){
Yuzu_uninstall(){
echo "Begin Yuzu uninstall"
rm -rf "$Yuzu_emuPath"
YuzuEA_uninstall
}
YuzuEA_uninstall(){
echo "Begin Yuzu EA uninstall"
rm -rf "$YuzuEA_emuPath"
}
#Migrate
Yuzu_migrate(){

View file

@ -479,6 +479,30 @@ function createDesktopShortcut(){
echo "$Shortcutlocation created"
}
#desktopShortcutFieldUpdate "$shortcutFile" "Name" "NewName"
function desktopShortcutFieldUpdate(){
local shortcutFile=$1
local shortcutKey=$2
local shortcutValue=$3
local name
local icon
if [ -f "$shortcutFile" ]; then
# update icon if name is updated
if [ "$shortcutKey" == "Name" ]; then
name=$shortcutValue
cp -v "$EMUDECKGIT/icons/$(cut -d " " -f1 <<< "$name")."{svg,jpg,png} "$HOME/.local/share/icons/emudeck/" 2>/dev/null
icon=$(find "$HOME/.local/share/icons/emudeck/" -type f -iname "$(cut -d " " -f1 <<< "$name").*")
if [ ! -z "$icon" ]; then
desktopShortcutFieldUpdate "$shortcutFile" "Icon" "$icon"
sed -i "s|Icon\s*?=.*|Icon=$icon|g" "$shortcutFile"
fi
fi
sed -E -i "s|$shortcutKey\s*?=.*|$shortcutKey=$shortcutValue|g" "$shortcutFile"
balooctl check
fi
}
#iniFieldUpdate "$iniFilePath" "General" "LoadPath" "$storagePath/$emuName/Load"
function iniFieldUpdate(){
local iniFile="$1"

BIN
icons/yuzu-EA.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -1,55 +1,54 @@
#!/bin/sh
emuName="yuzu" #parameterize me
emufolder="$HOME/Applications" # has to be applications for ES-DE to find it
emuExeFile=$(find $emufolder -iname "${emuName}*.AppImage" | sort -n | cut -d' ' -f 2- | tail -n 1 2>/dev/null)
# update check only if we're not launching yuzu-ea...
isMainline=true
if [ ! "$emuExeFile" == "$emufolder/$emuName.AppImage" ]; then
isMainline=false
fi
if [ -z "$1" ] && [ "$isMainline" = true ]; then
echo "Yuzu mainline detected, checking connectivity"
if [ -z "$1" ]; then
echo $1
if : >/dev/tcp/8.8.8.8/53; then
echo 'Internet available. Check for Update'
yuzuHost="https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases/latest"
metaData=$(curl ${yuzuHost})
metaData=$(curl -fSs ${yuzuHost})
fileToDownload=$(echo ${metaData} | jq -r '.assets[] | select(.name|test(".*.AppImage$")).browser_download_url')
currentVer=$(echo ${metaData} | jq -r '.tag_name')
lastDL="$HOME/emudeck/yuzu.ver"
if [ "$currentVer" == "$(cat ${lastDL})" ] ;then
echo "no need to update."
elif [ -z $currentVer ] ;then
echo "couldn't get metadata."
else
zenity --question --title="Yuzu update available!" --width 200 --text "Yuzu ${currentVer} available. Would you like to update?" --ok-label="Yes" --cancel-label="No" 2>/dev/null
if [[ $? == 0 ]]; then
echo "download ${currentVer} appimage: ${fileToDownload}"
response=$(curl -L -X GET ${fileToDownload} --write-out '%{http_code}' -H "Accept: application/json" -o "${HOME}/Applications/${emuName}.AppImage")
if [ "$response" = "200" ] ; then
echo "downloaded successfully"
echo ${currentVer} > ${lastDL}
chmod +x "${HOME}/Applications/${emuName}.AppImage"
elif [ "$response" = "401" ] ; then
echo "Not authorized."
else
echo "Download errored with code $response"
fi
fi
fi
if [ "$currentVer" == "$(cat ${lastDL})" ] ;then
echo "no need to update."
elif [ -z $currentVer ] ;then
echo "couldn't get metadata."
else
echo 'Offline'
zenity --question --title="Yuzu update available!" --width 200 --text "Yuzu ${currentVer} available. Would you like to update?" --ok-label="Yes" --cancel-label="No" 2>/dev/null
if [[ $? == 0 ]]; then
echo "download ${currentVer} appimage: ${fileToDownload}"
response=$(curl -L -X GET ${fileToDownload} --write-out '%{http_code}' -H "Accept: application/json" -o "${HOME}/Applications/${emuName}.AppImage")
if [ "$response" = "200" ] ; then
echo "downloaded successfully"
echo ${currentVer} > ${lastDL}
chmod +x "${HOME}/Applications/${emuName}.AppImage"
elif [ "$response" = "401" ] ; then
echo "Not authorized."
else
echo "Download errored with code $response"
fi
fi
fi
else
echo 'Offline'
fi
fi
#find full path to emu executable
exe="prlimit --nofile=8192 $(find $emufolder -iname "${emuName}*.AppImage" | sort -n | cut -d' ' -f 2- | tail -n 1 2>/dev/null)"
exe="prlimit --nofile=8192 ${emuExeFile}"
#run the executable with the params.
#Fix first '