2021-12-24 21:56:49 +00:00
|
|
|
// Modules to control application life and create native browser window
|
2022-06-14 15:02:37 +00:00
|
|
|
import {app, BrowserWindow, session} from "electron";
|
2021-12-26 19:15:18 +00:00
|
|
|
import "v8-compile-cache";
|
2022-06-14 15:02:37 +00:00
|
|
|
import {getConfig, checkIfConfigExists, injectElectronFlags} from "./utils";
|
2021-12-26 21:41:09 +00:00
|
|
|
import "./extensions/mods";
|
2021-12-26 19:15:18 +00:00
|
|
|
import "./extensions/plugin";
|
|
|
|
import "./tray";
|
2022-06-14 15:02:37 +00:00
|
|
|
import {createCustomWindow, createNativeWindow} from "./window";
|
2022-01-15 21:21:51 +00:00
|
|
|
import "./shortcuts";
|
2022-04-18 11:03:26 +00:00
|
|
|
|
2022-01-30 19:48:32 +00:00
|
|
|
export var settings: any;
|
|
|
|
export var customTitlebar: boolean;
|
2022-07-04 14:39:22 +00:00
|
|
|
export var clientName: "ArmCord";
|
2021-12-24 21:56:49 +00:00
|
|
|
|
2022-04-22 18:30:09 +00:00
|
|
|
if (process.platform == "linux") {
|
|
|
|
if (process.env.$XDG_SESSION_TYPE == "wayland") {
|
2022-05-22 11:52:26 +00:00
|
|
|
console.log("Wayland specific patches applied.");
|
2022-04-22 18:30:09 +00:00
|
|
|
app.commandLine.appendSwitch("ozone-platform=wayland");
|
2022-04-22 18:39:00 +00:00
|
|
|
if (process.env.$XDG_CURRENT_DESKTOP == "GNOME") {
|
|
|
|
app.commandLine.appendSwitch("enable-features=UseOzonePlatform,WaylandWindowDecorations");
|
|
|
|
} else {
|
|
|
|
app.commandLine.appendSwitch("enable-features=UseOzonePlatform");
|
|
|
|
}
|
2022-04-22 18:30:09 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-18 11:03:26 +00:00
|
|
|
checkIfConfigExists();
|
2022-06-10 18:24:13 +00:00
|
|
|
injectElectronFlags();
|
2022-01-30 19:48:32 +00:00
|
|
|
app.whenReady().then(async () => {
|
2022-04-18 10:25:10 +00:00
|
|
|
switch (await getConfig("windowStyle")) {
|
2022-02-26 21:26:16 +00:00
|
|
|
case "default":
|
2022-03-04 17:53:18 +00:00
|
|
|
createCustomWindow();
|
|
|
|
customTitlebar = true;
|
|
|
|
break;
|
2022-02-26 21:26:16 +00:00
|
|
|
case "native":
|
2022-03-04 17:53:18 +00:00
|
|
|
createNativeWindow();
|
2022-04-20 19:50:23 +00:00
|
|
|
break;
|
2022-07-04 14:39:22 +00:00
|
|
|
case "basic":
|
2022-04-20 19:50:23 +00:00
|
|
|
createNativeWindow();
|
2022-03-04 17:53:18 +00:00
|
|
|
break;
|
2022-02-26 21:26:16 +00:00
|
|
|
default:
|
2022-03-04 17:53:18 +00:00
|
|
|
createCustomWindow();
|
|
|
|
customTitlebar = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
|
|
|
if (permission === "notifications") {
|
|
|
|
// Approves the permissions request
|
|
|
|
callback(true);
|
|
|
|
}
|
|
|
|
if (permission === "media") {
|
|
|
|
// Approves the permissions request
|
|
|
|
callback(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
app.on("activate", async function () {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0)
|
2022-04-18 10:25:10 +00:00
|
|
|
switch (await getConfig("windowStyle")) {
|
2022-03-04 17:53:18 +00:00
|
|
|
case "default":
|
|
|
|
createCustomWindow();
|
|
|
|
break;
|
|
|
|
case "native":
|
|
|
|
createNativeWindow();
|
|
|
|
break;
|
2022-06-14 15:02:37 +00:00
|
|
|
case "discord":
|
|
|
|
createNativeWindow();
|
2022-03-04 17:53:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
createCustomWindow();
|
|
|
|
break;
|
|
|
|
}
|
2022-07-04 14:39:22 +00:00
|
|
|
console.log("userDataPath = " + app.getPath("userData"));
|
2022-03-04 17:53:18 +00:00
|
|
|
});
|
2021-12-26 19:15:18 +00:00
|
|
|
});
|
2021-12-24 21:56:49 +00:00
|
|
|
|
2021-12-26 19:15:18 +00:00
|
|
|
app.on("window-all-closed", function () {
|
2022-03-04 17:53:18 +00:00
|
|
|
if (process.platform !== "darwin") app.quit();
|
2021-12-26 19:15:18 +00:00
|
|
|
});
|