2021-12-24 21:56:49 +00:00
|
|
|
// Modules to control application life and create native browser window
|
2022-12-13 13:10:41 +00:00
|
|
|
import {app, BrowserWindow, crashReporter, session} from "electron";
|
2021-12-26 19:15:18 +00:00
|
|
|
import "v8-compile-cache";
|
2022-12-13 13:10:41 +00:00
|
|
|
import {
|
|
|
|
checkForDataFolder,
|
|
|
|
getConfig,
|
|
|
|
checkIfConfigExists,
|
|
|
|
injectElectronFlags,
|
|
|
|
installModLoader,
|
|
|
|
getConfigLocation
|
|
|
|
} from "./utils";
|
2021-12-26 21:41:09 +00:00
|
|
|
import "./extensions/mods";
|
2021-12-26 19:15:18 +00:00
|
|
|
import "./tray";
|
2022-12-13 13:10:41 +00:00
|
|
|
import fs from "fs";
|
2022-11-19 17:23:28 +00:00
|
|
|
import {createCustomWindow, createNativeWindow, createTransparentWindow, mainWindow} from "./window";
|
2022-08-25 14:42:54 +00:00
|
|
|
import path from "path";
|
|
|
|
export var iconPath: string;
|
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-12-13 13:10:41 +00:00
|
|
|
// Your data now belongs to CCP
|
|
|
|
let settingsFile = fs.readFileSync(getConfigLocation(), "utf-8");
|
|
|
|
crashReporter.start({uploadToServer: false, extra: {settingsFile}});
|
|
|
|
|
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-12-13 13:10:41 +00:00
|
|
|
|
2022-12-03 16:21:25 +00:00
|
|
|
checkForDataFolder();
|
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-09-25 18:30:09 +00:00
|
|
|
if ((await getConfig("customIcon")) !== undefined ?? null) {
|
|
|
|
iconPath = await getConfig("customIcon");
|
2022-08-25 14:42:54 +00:00
|
|
|
} else {
|
2022-09-25 18:30:09 +00:00
|
|
|
iconPath = path.join(__dirname, "../", "/assets/ac_icon_transparent.png");
|
2022-08-25 14:42:54 +00:00
|
|
|
}
|
2022-07-11 18:19:50 +00:00
|
|
|
async function init() {
|
|
|
|
switch (await getConfig("windowStyle")) {
|
|
|
|
case "default":
|
|
|
|
createCustomWindow();
|
|
|
|
customTitlebar = true;
|
|
|
|
break;
|
|
|
|
case "native":
|
|
|
|
createNativeWindow();
|
|
|
|
break;
|
2022-10-08 15:43:08 +00:00
|
|
|
case "transparent":
|
|
|
|
createTransparentWindow();
|
|
|
|
break;
|
2022-07-11 18:19:50 +00:00
|
|
|
case "basic":
|
|
|
|
createNativeWindow();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
createCustomWindow();
|
|
|
|
customTitlebar = true;
|
|
|
|
break;
|
|
|
|
}
|
2022-03-04 17:53:18 +00:00
|
|
|
}
|
2022-08-22 09:24:55 +00:00
|
|
|
await init();
|
2022-11-21 05:50:21 +00:00
|
|
|
await installModLoader();
|
2022-03-04 17:53:18 +00:00
|
|
|
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 () {
|
2022-08-22 09:24:55 +00:00
|
|
|
if (BrowserWindow.getAllWindows().length === 0) await init();
|
2022-03-04 17:53:18 +00:00
|
|
|
});
|
2021-12-26 19:15:18 +00:00
|
|
|
});
|