aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Ava/Program.cs')
-rw-r--r--Ryujinx.Ava/Program.cs54
1 files changed, 52 insertions, 2 deletions
diff --git a/Ryujinx.Ava/Program.cs b/Ryujinx.Ava/Program.cs
index 836801c8..5d88466e 100644
--- a/Ryujinx.Ava/Program.cs
+++ b/Ryujinx.Ava/Program.cs
@@ -13,8 +13,10 @@ using Ryujinx.Ui.Common;
using Ryujinx.Ui.Common.Configuration;
using Ryujinx.Ui.Common.Helper;
using System;
+using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Threading.Tasks;
namespace Ryujinx.Ava
@@ -32,9 +34,51 @@ namespace Ryujinx.Ava
private const uint MB_ICONWARNING = 0x30;
+ [SupportedOSPlatform("linux")]
+ static void RegisterMimeTypes()
+ {
+ if (ReleaseInformation.IsFlatHubBuild())
+ {
+ return;
+ }
+
+ string mimeDbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "mime");
+
+ if (!File.Exists(Path.Combine(mimeDbPath, "packages", "Ryujinx.xml")))
+ {
+ string mimeTypesFile = Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "mime", "Ryujinx.xml");
+ using Process mimeProcess = new();
+
+ mimeProcess.StartInfo.FileName = "xdg-mime";
+ mimeProcess.StartInfo.Arguments = $"install --novendor --mode user {mimeTypesFile}";
+
+ mimeProcess.Start();
+ mimeProcess.WaitForExit();
+
+ if (mimeProcess.ExitCode != 0)
+ {
+ Logger.Error?.PrintMsg(LogClass.Application, $"Unable to install mime types. Make sure xdg-utils is installed. Process exited with code: {mimeProcess.ExitCode}");
+ return;
+ }
+
+ using Process updateMimeProcess = new();
+
+ updateMimeProcess.StartInfo.FileName = "update-mime-database";
+ updateMimeProcess.StartInfo.Arguments = mimeDbPath;
+
+ updateMimeProcess.Start();
+ updateMimeProcess.WaitForExit();
+
+ if (updateMimeProcess.ExitCode != 0)
+ {
+ Logger.Error?.PrintMsg(LogClass.Application, $"Could not update local mime database. Process exited with code: {updateMimeProcess.ExitCode}");
+ }
+ }
+ }
+
public static void Main(string[] args)
{
- Version = ReleaseInformations.GetVersion();
+ Version = ReleaseInformation.GetVersion();
if (OperatingSystem.IsWindows() && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 17134))
{
@@ -93,6 +137,12 @@ namespace Ryujinx.Ava
// Initialize the logger system.
LoggerModule.Initialize();
+ // Register mime types on linux.
+ if (OperatingSystem.IsLinux())
+ {
+ RegisterMimeTypes();
+ }
+
// Initialize Discord integration.
DiscordIntegrationModule.Initialize();
@@ -218,4 +268,4 @@ namespace Ryujinx.Ava
Logger.Shutdown();
}
}
-}
+} \ No newline at end of file