diff --git a/src/main/constants.ts b/src/main/constants.ts index 8c30b03..d5c5fa6 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -11,6 +11,7 @@ export const DATA_DIR = process.env.VENCORD_USER_DATA_DIR || join(app.getPath("u export const VENCORD_SETTINGS_DIR = join(DATA_DIR, "settings"); export const VENCORD_QUICKCSS_FILE = join(VENCORD_SETTINGS_DIR, "quickCss.css"); export const VENCORD_SETTINGS_FILE = join(VENCORD_SETTINGS_DIR, "settings.json"); +export const VENCORD_THEMES_DIR = join(DATA_DIR, "themes"); // needs to be inline require because of circular dependency // as otherwise "DATA_DIR" (which is used by ./settings) will be uninitialised diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 10181d2..648c34c 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -5,7 +5,7 @@ */ import { app, dialog, ipcMain, session, shell } from "electron"; -import { existsSync, readFileSync, watch } from "fs"; +import { existsSync, mkdirSync, readFileSync, watch } from "fs"; import { open, readFile } from "fs/promises"; import { release } from "os"; import { join } from "path"; @@ -14,7 +14,7 @@ import { debounce } from "shared/utils/debounce"; import { IpcEvents } from "../shared/IpcEvents"; import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; -import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE } from "./constants"; +import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; import { mainWin } from "./mainWindow"; import { Settings } from "./settings"; @@ -122,3 +122,12 @@ open(VENCORD_QUICKCSS_FILE, "a+").then(fd => { }, 50) ); }); + +mkdirSync(VENCORD_THEMES_DIR, { recursive: true }); +watch( + VENCORD_THEMES_DIR, + { persistent: false }, + debounce(() => { + mainWin?.webContents.postMessage("VencordThemeUpdate", void 0); + }) +);