feat: dynamic change tray bg color on theme change
This commit is contained in:
parent
42c1cc02f0
commit
fccbb7f5a5
2 changed files with 8 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { dialog, NativeImage, nativeImage } from "electron";
|
import { dialog, NativeImage, nativeImage, nativeTheme } from "electron";
|
||||||
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
||||||
import { readFile } from "fs/promises";
|
import { readFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
@ -185,3 +185,7 @@ export async function pickTrayIcon(iconName: string) {
|
||||||
export async function getIconWithBadge(dataURL: string) {
|
export async function getIconWithBadge(dataURL: string) {
|
||||||
tray.setImage(nativeImage.createFromDataURL(dataURL));
|
tray.setImage(nativeImage.createFromDataURL(dataURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nativeTheme.on("updated", () => {
|
||||||
|
generateTrayIcons();
|
||||||
|
});
|
||||||
|
|
|
@ -32,8 +32,10 @@ function changeColorsInSvg(svg: string, stockColor: string) {
|
||||||
const fillColor = VesktopNative.settings.get().trayAutoFill ?? "auto";
|
const fillColor = VesktopNative.settings.get().trayAutoFill ?? "auto";
|
||||||
const reg = new RegExp(stockColor, "gim");
|
const reg = new RegExp(stockColor, "gim");
|
||||||
svg = svg.replace(reg, "#" + (pickedColor ?? stockColor));
|
svg = svg.replace(reg, "#" + (pickedColor ?? stockColor));
|
||||||
if (fillColor !== "auto") {
|
|
||||||
|
if (fillColor === "white") {
|
||||||
svg = svg.replace(/black/gim, fillColor);
|
svg = svg.replace(/black/gim, fillColor);
|
||||||
|
} else if (fillColor === "black") {
|
||||||
svg = svg.replace(/white/gim, fillColor);
|
svg = svg.replace(/white/gim, fillColor);
|
||||||
}
|
}
|
||||||
return svg;
|
return svg;
|
||||||
|
|
Loading…
Reference in a new issue