From 5c109f530b933ed74e2ac22335d66e26dff036fc Mon Sep 17 00:00:00 2001 From: smartfridge <37928912+smartfrigde@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:42:54 +0200 Subject: [PATCH] Add custom icon --- src/main.ts | 8 +++++++- src/settings/preload.ts | 5 ++++- src/window.ts | 8 ++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3de5dd8..615b931 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,8 @@ import "./extensions/mods"; import "./extensions/plugin"; import "./tray"; import {createCustomWindow, createNativeWindow} from "./window"; - +import path from "path"; +export var iconPath: string; export var settings: any; export var customTitlebar: boolean; export var clientName: "ArmCord"; @@ -25,6 +26,11 @@ if (process.platform == "linux") { checkIfConfigExists(); injectElectronFlags(); app.whenReady().then(async () => { + if (await getConfig("customIcon") !== undefined ?? null) { + iconPath = await getConfig("customIcon") + } else { + iconPath = path.join(__dirname, "../", "/assets/ac_icon_transparent.png") + } async function init() { switch (await getConfig("windowStyle")) { case "default": diff --git a/src/settings/preload.ts b/src/settings/preload.ts index 26c56d2..ce4876c 100644 --- a/src/settings/preload.ts +++ b/src/settings/preload.ts @@ -20,6 +20,9 @@ contextBridge.exposeInMainWorld("settings", { copyDebugInfo: () => ipcRenderer.send("copyDebugInfo") }); if (ipcRenderer.sendSync("getLangName") == "en-US") { + console.log("[Settings]: Lang " + ipcRenderer.sendSync("getLangName")); const cssPath = path.join(__dirname, "../", "/content/css/settingsEng.css"); - addStyle(fs.readFileSync(cssPath, "utf8")); + document.addEventListener("DOMContentLoaded", function (event) { + addStyle(fs.readFileSync(cssPath, "utf8")); + }); } diff --git a/src/window.ts b/src/window.ts index 429a466..1ae89bb 100644 --- a/src/window.ts +++ b/src/window.ts @@ -20,7 +20,7 @@ import startServer from "./socket"; import contextMenu from "electron-context-menu"; import os from "os"; import {tray} from "./tray"; -export var icon: string; +import {iconPath} from "./main"; export let mainWindow: BrowserWindow; export let inviteWindow: BrowserWindow; var osType = os.type(); @@ -203,7 +203,7 @@ export function createCustomWindow() { height: 350, title: "ArmCord", darkTheme: true, - icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), + icon: iconPath, frame: false, autoHideMenuBar: true, webPreferences: { @@ -220,7 +220,7 @@ export function createNativeWindow() { height: 350, title: "ArmCord", darkTheme: true, - icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), + icon: iconPath, frame: true, autoHideMenuBar: true, webPreferences: { @@ -238,7 +238,7 @@ export function createInviteWindow() { height: 600, title: "ArmCord Invite Manager", darkTheme: true, - icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), + icon: iconPath, frame: true, autoHideMenuBar: true, webPreferences: {