Fixing tray icon color on macOS Big Sur (#1595)
* Using trayTemplate icon Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Clean up nativeTheme import Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Using light icon for tray Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Removing unused tray icons Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
|
Before Width: | Height: | Size: 478 B After Width: | Height: | Size: 478 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 973 B |
|
Before Width: | Height: | Size: 1.4 KiB |
@ -1,6 +1,6 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import packageInfo from "../../package.json";
|
import packageInfo from "../../package.json";
|
||||||
import { dialog, Menu, NativeImage, nativeTheme, Tray } from "electron";
|
import { dialog, Menu, NativeImage, Tray } from "electron";
|
||||||
import { autorun } from "mobx";
|
import { autorun } from "mobx";
|
||||||
import { showAbout } from "./menu";
|
import { showAbout } from "./menu";
|
||||||
import { AppUpdater } from "./app-updater";
|
import { AppUpdater } from "./app-updater";
|
||||||
@ -16,14 +16,11 @@ import { exitApp } from "./exit-app";
|
|||||||
// note: instance of Tray should be saved somewhere, otherwise it disappears
|
// note: instance of Tray should be saved somewhere, otherwise it disappears
|
||||||
export let tray: Tray;
|
export let tray: Tray;
|
||||||
|
|
||||||
// refresh icon when MacOS dark/light theme has changed
|
export function getTrayIcon(): string {
|
||||||
nativeTheme?.on("updated", () => tray?.setImage(getTrayIcon()));
|
|
||||||
|
|
||||||
export function getTrayIcon(isDark = nativeTheme.shouldUseDarkColors): string {
|
|
||||||
return path.resolve(
|
return path.resolve(
|
||||||
__static,
|
__static,
|
||||||
isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras
|
isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras
|
||||||
`tray_icon${isDark ? "_dark" : ""}.png`
|
"trayIconTemplate.png"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||