1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// 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<JsonObject>(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);
}
}
|