diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index ee2f206f..f3d151d4 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -397,7 +397,6 @@ export class BrowserWindow { ipcMain.on("get-themes", (event, _key) => { if (existsSync(utils.getPath("themes"))) { - // return any .less files and scan any folders in the themes folder for .less files let files = readdirSync(utils.getPath("themes")); let themes = []; for (let file of files) { @@ -412,7 +411,39 @@ export class BrowserWindow { } } } - event.returnValue = themes; + let themeObjects = []; + for (let theme of themes) { + let themePath = join(utils.getPath("themes"), theme); + let themeName = theme; + let themeDescription = ""; + if (theme.includes("/")) { + themeName = theme.split("/")[1]; + themeDescription = theme.split("/")[0]; + } + if (themePath.endsWith("index.less")) { + themePath = themePath.slice(0, -10); + } + if (existsSync(join(themePath, "theme.json"))) { + let themeJson = JSON.parse(readFileSync(join(themePath, "theme.json"), "utf8")); + themeObjects.push({ + name: themeJson.name || themeName, + description: themeJson.description || themeDescription, + path: themePath, + file: theme, + test: join(themePath, "theme.json") + }); + } else { + themeObjects.push({ + name: themeName, + description: themeDescription, + path: themePath, + file: theme, + test: join(themePath, "theme.json") + }); + } + } + event.returnValue = themeObjects; + } else { event.returnValue = []; } diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 76e1b8b5..87b23311 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -130,7 +130,7 @@