// 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)); // skip updates discordSettings!["SKIP_HOST_UPDATE"] = true; discordSettings!["SKIP_MODULE_UPDATE"] = true; //discordSettings!["ALWAYS_ALLOW_UPDATES"] = false; //discordSettings!["ALWAYS_BOOTSTRAP_MODULES"] = false; discordSettings!["USE_LOCAL_MODULE_VERSIONS"] = true; // enable devtools discordSettings!["DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING"] = true; // various behavior changes discordSettings!["WEBAPP_ENDPOINT"] = "https://dev.app.spacebar.chat"; discordSettings!["trayBalloonShown"] = true; // We don't need to be re-introduced to how system trays work discordSettings!["MIN_WIDTH"] = 1; discordSettings!["MIN_HEIGHT"] = 1; discordSettings!["BACKGROUND_COLOR"] = "#0000FF"; File.WriteAllText(settingsJsonPath, JsonSerializer.Serialize(discordSettings)); Console.WriteLine($"Wrote settings.json... Contents: {discordSettings}"); Console.WriteLine($"Full path: {settingsJsonPath}"); } var psi = new ProcessStartInfo(discordClientPath, ["--allow-insecure-localhost", "--disable-features=OutOfBlinkCors"]) { Environment = { // { "DISCORD_WEBAPP_ENDPOINT", "http://discord.localhost" }, { "DISCORD_USER_DATA_DIR", userDataPath }, } }; Process.Start(psi); } }