From 34a9922b57b582fb18a670241f7efe43d4723fe7 Mon Sep 17 00:00:00 2001 From: Alex0007 Date: Tue, 23 Jan 2024 02:10:25 +0400 Subject: [PATCH] Fix architecture preference for MacOS game shortcuts (#6145) * Fix architecture preference for MacOS game shortcuts * Detect arch and then pass it to script Co-authored-by: jcm * Remove old script write call in `CreateShortcutMacos` * Turn launch script into EmbeddedResource * Added final newline --------- Co-authored-by: jcm --- distribution/macos/shortcut-launch-script.sh | 8 ++++++++ src/Ryujinx.Ui.Common/Helper/ShortcutHelper.cs | 4 ++-- src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 distribution/macos/shortcut-launch-script.sh diff --git a/distribution/macos/shortcut-launch-script.sh b/distribution/macos/shortcut-launch-script.sh new file mode 100644 index 0000000000..784d780aa2 --- /dev/null +++ b/distribution/macos/shortcut-launch-script.sh @@ -0,0 +1,8 @@ +#!/bin/sh +launch_arch="$(uname -m)" +if [ "$(sysctl -in sysctl.proc_translated)" = "1" ] +then + launch_arch="arm64" +fi + +arch -$launch_arch {0} {1} diff --git a/src/Ryujinx.Ui.Common/Helper/ShortcutHelper.cs b/src/Ryujinx.Ui.Common/Helper/ShortcutHelper.cs index 97b9853dbd..60b9289859 100644 --- a/src/Ryujinx.Ui.Common/Helper/ShortcutHelper.cs +++ b/src/Ryujinx.Ui.Common/Helper/ShortcutHelper.cs @@ -54,6 +54,7 @@ namespace Ryujinx.Ui.Common.Helper { string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx"); var plistFile = EmbeddedResources.ReadAllText("Ryujinx.Ui.Common/shortcut-template.plist"); + var shortcutScript = EmbeddedResources.ReadAllText("Ryujinx.Ui.Common/shortcut-launch-script.sh"); // Macos .App folder string contentFolderPath = Path.Combine("/Applications", cleanedAppName + ".app", "Contents"); string scriptFolderPath = Path.Combine(contentFolderPath, "MacOS"); @@ -68,8 +69,7 @@ namespace Ryujinx.Ui.Common.Helper string scriptPath = Path.Combine(scriptFolderPath, ScriptName); using StreamWriter scriptFile = new(scriptPath); - scriptFile.WriteLine("#!/bin/sh"); - scriptFile.WriteLine($"{basePath} {GetArgsString(appFilePath)}"); + scriptFile.Write(shortcutScript, basePath, GetArgsString(appFilePath)); // Set execute permission FileInfo fileInfo = new(scriptPath); diff --git a/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj b/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj index 74331fdef6..1a8c216aa5 100644 --- a/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj +++ b/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj @@ -51,6 +51,7 @@ +