From 456f8ba163026d77b1b60aaf0b20bd2e14d1e2c3 Mon Sep 17 00:00:00 2001 From: SuperSonic16 <25761885+thesupersonic16@users.noreply.github.com> Date: Sun, 13 Oct 2024 01:06:51 +1100 Subject: [PATCH] Fixed URL handler on Linux --- HedgeModManager/Linux.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/HedgeModManager/Linux.cs b/HedgeModManager/Linux.cs index bd784f28..73a54469 100644 --- a/HedgeModManager/Linux.cs +++ b/HedgeModManager/Linux.cs @@ -75,7 +75,7 @@ public static bool GenerateDesktop() // GameBanana foreach (Game game in Games.GetSupportedGames()) - GenerateDesktopAndRegister($"{game.GBProtocol}.desktop", $"Hedge Mod Manager ({game.GameName})", $"{baseExec} -gb \"%u\"", icon, false, $"x-scheme-handler/{game.GBProtocol}"); + GenerateDesktopAndRegister($"{game.GBProtocol}.desktop", $"Hedge Mod Manager ({game.GameName})", $"{baseExec} \"-gb %u\"", icon, false, $"x-scheme-handler/{game.GBProtocol}"); } return true; @@ -90,6 +90,7 @@ public static bool GenerateDesktopAndRegister(string fileName, string name, stri { string directory = Path.Combine(GetHomeDirectory(), ".local/share/applications"); string mimeappsPath = Path.Combine(GetHomeDirectory(), ".config/mimeapps.list"); + string mimeCachePath = Path.Combine(directory, "mimeinfo.cache"); string filePath = Path.Combine(directory, fileName); // Create applications folder @@ -127,6 +128,19 @@ public static bool GenerateDesktopAndRegister(string fileName, string name, stri using (var stream = File.OpenWrite(mimeappsPath)) mimeapps.Write(stream); + // Write to cache + IniFile mimeCache; + if (!File.Exists(mimeCachePath)) + mimeCache = new IniFile(); + else + mimeCache = new IniFile(mimeCachePath); + + mimeCache.UseQuotes = false; + mimeCache["MIME Cache"][mimeType] = fileName + ';'; + + using (var stream = File.OpenWrite(mimeCachePath)) + mimeCache.Write(stream); + return true; }