// See https://aka.ms/new-console-template for more information using System.Diagnostics; using System.Text.Json; using System.Text.Json.Nodes; using SpacebarDiscordDesktopLauncher; internal class Program { public static void Main(string[] args) { string? discordClientPath = Environment.OSVersion.Platform switch { PlatformID.Win32NT => WindowsDiscordClientFinder.FindDiscord(), PlatformID.Unix => LinuxDiscordClientFinder.FindDiscord(), _ => throw new Exception($"Unknown platform: {Environment.OSVersion.Platform}") }; string? userDataPath = Environment.OSVersion.Platform switch { PlatformID.Win32NT => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "Discord-SpacebarLauncher"), PlatformID.Unix => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "Discord-SpacebarLauncher"), _ => throw new Exception($"Unknown platform: {Environment.OSVersion.Platform}") }; if (discordClientPath is null) { Console.WriteLine("Could not find Discord! Do you have the normal Discord client installed?"); Console.ReadLine(); return; } if (Environment.OSVersion.Platform == PlatformID.Unix) { var settingsJsonPath = Path.Combine(userDataPath, "discord", "settings.json"); JsonObject discordSettings = new(); if (File.Exists(settingsJsonPath)) discordSettings = JsonSerializer.Deserialize(File.ReadAllText(settingsJsonPath)); discordSettings!["SKIP_HOST_UPDATE"] = true; File.WriteAllText(settingsJsonPath, JsonSerializer.Serialize(discordSettings)); Console.WriteLine($"Wrote settings.json... Contents: {discordSettings}"); Console.WriteLine($"Full path: {settingsJsonPath}"); } var psi = new ProcessStartInfo(discordClientPath) { Environment = { { "DISCORD_WEBAPP_ENDPOINT", "https://app.spacebar.chat" }, { "DISCORD_USER_DATA_DIR", userDataPath }, } }; Process.Start(psi); } }