mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Add theme loader
This commit is contained in:
parent
b7a0d1face
commit
a216475618
4 changed files with 33 additions and 14 deletions
|
@ -11,7 +11,6 @@ import "./shortcuts";
|
|||
export var settings: any;
|
||||
export var customTitlebar: boolean;
|
||||
|
||||
|
||||
if (process.platform == "linux") {
|
||||
if (process.env.$XDG_SESSION_TYPE == "wayland") {
|
||||
console.log("Wayland specific patches applied.");
|
||||
|
|
|
@ -28,6 +28,9 @@ const clientMods = {
|
|||
};
|
||||
|
||||
console.log("ArmCord");
|
||||
ipcRenderer.on("themeLoader", (event, message) => {
|
||||
addStyle(message);
|
||||
});
|
||||
if (window.location.href.indexOf("splash.html") > -1) {
|
||||
console.log("Skipping titlebar injection and client mod injection.");
|
||||
} else {
|
||||
|
|
|
@ -52,6 +52,3 @@ export function injectTitlebar() {
|
|||
});
|
||||
});
|
||||
}
|
||||
export function removeTitlebar() {
|
||||
document.querySelector("#titlebar")!.remove();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import {BrowserWindow, shell, app, dialog} from "electron";
|
|||
import path from "path";
|
||||
import { checkIfConfigIsBroken, firstRun, getConfig, contentPath, isSetup, setConfig, setLang, setWindowState } from "./utils";
|
||||
import { registerIpc } from "./ipc";
|
||||
import * as fs from "fs";
|
||||
import startServer from "./socket";
|
||||
import contextMenu from "electron-context-menu";
|
||||
import os from "os";
|
||||
|
@ -71,6 +72,25 @@ async function doAfterDefiningTheWindow() {
|
|||
if (/api\/v\d\/science$/g.test(details.url)) return callback({ cancel: true });
|
||||
return callback({});
|
||||
});
|
||||
const userDataPath = app.getPath("userData");
|
||||
const themesFolder = userDataPath + "/themes/";
|
||||
if (!fs.existsSync(themesFolder)) {
|
||||
fs.mkdirSync(themesFolder);
|
||||
console.log("Created missing theme folder");
|
||||
}
|
||||
mainWindow.webContents.on('did-finish-load', () => {
|
||||
fs.readdirSync(themesFolder).forEach((file) => {
|
||||
try {
|
||||
const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8");
|
||||
var themeFile = JSON.parse(manifest);
|
||||
mainWindow.webContents.send("themeLoader", fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8"))
|
||||
console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red");
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mainWindow.on("close", async (e) => {
|
||||
let [width, height] = mainWindow.getSize()
|
||||
setWindowState({
|
||||
|
|
Loading…
Reference in a new issue