A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
desktop: style tray icons based on actual system theme
Abdullah Atta70d4e99dc12e
diff --git a/apps/web/desktop/asset-manager.ts b/apps/web/desktop/asset-manager.tsindex 9c15180fc..a50be690b 100644--- a/apps/web/desktop/asset-manager.ts+++ b/apps/web/desktop/asset-manager.ts@@ -17,11 +17,12 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { NativeImage, nativeImage, nativeTheme } from "electron";+import { NativeImage, nativeImage } from "electron";import path from "path";import { isDevelopment } from "./utils";import { parse, ParsedImage } from "icojs";import { readFileSync } from "fs";+import { getSystemTheme } from "./config/theme";type Formats = "ico" | "png" | "icns";type IconOptions<TFormat extends Formats> = {@@ -86,7 +87,7 @@ export class AssetManager {): FlexibleIcon<TFormat> | undefined {const { size = 16, format = "png" } = options;- const prefix: Prefixes = nativeTheme.shouldUseDarkColors ? ".dark" : "";+ const prefix: Prefixes = getSystemTheme() === "dark" ? ".dark" : "";const icoPath = path.join(RESOURCES_DIR,diff --git a/apps/web/desktop/config/theme.js b/apps/web/desktop/config/theme.jsindex 12de6c881..3e6cf612a 100644--- a/apps/web/desktop/config/theme.js+++ b/apps/web/desktop/config/theme.js@@ -35,6 +35,23 @@ function getBackgroundColor() {return nativeTheme.shouldUseDarkColors ? "#0f0f0f" : "#ffffff";}+function getSystemTheme() {+ const listeners = nativeTheme.rawListeners("updated");+ nativeTheme.removeAllListeners("updated");++ const oldThemeSource = nativeTheme.themeSource;+ nativeTheme.themeSource = "system";+ const currentTheme = nativeTheme.shouldUseDarkColors ? "dark" : "light";+ nativeTheme.themeSource = oldThemeSource;++ setTimeout(+ () => listeners.forEach((a) => nativeTheme.addListener("updated", a)),+ 1000+ );+ return currentTheme;+}++export { getTheme, setTheme, getBackgroundColor, getSystemTheme };function changeTheme(theme) {const listeners = nativeTheme.rawListeners("updated");