Skip to content

Commit 75eb1c8

Browse files
authored
fix: dark mode not toggling with system (#515)
1 parent 8b186a9 commit 75eb1c8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

main.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { ipcMain, app } = require('electron');
1+
const { ipcMain, app, nativeTheme } = require('electron');
22
const { menubar } = require('menubar');
33
const { autoUpdater } = require('electron-updater');
44
const { onFirstRunMaybe } = require('./first-run');
@@ -54,6 +54,14 @@ menubarApp.on('ready', () => {
5454

5555
autoUpdater.checkForUpdatesAndNotify();
5656

57+
nativeTheme.on('updated', () => {
58+
if (nativeTheme.shouldUseDarkColors) {
59+
menubarApp.window.webContents.send('update-native-theme', 'DARK');
60+
} else {
61+
menubarApp.window.webContents.send('update-native-theme', 'LIGHT');
62+
}
63+
});
64+
5765
ipcMain.on('reopen-window', () => menubarApp.showWindow());
5866
ipcMain.on('app-quit', () => menubarApp.app.quit());
5967
ipcMain.on('update-icon', (_, arg) => {

src/routes/Settings.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ import { IconAddAccount } from '../icons/AddAccount';
1111
import { IconLogOut } from '../icons/Logout';
1212
import { IconQuit } from '../icons/Quit';
1313
import { updateTrayIcon } from '../utils/comms';
14+
import { setAppearance } from '../utils/appearance';
1415

1516
const isLinux = remote.process.platform === 'linux';
1617

1718
export const SettingsRoute: React.FC = () => {
1819
const { settings, updateSetting, logout } = useContext(AppContext);
1920
const history = useHistory();
2021

22+
ipcRenderer.on('update-native-theme', (_, updatedAppearance: Appearance) => {
23+
if (settings.appearance === Appearance.SYSTEM) {
24+
setAppearance(updatedAppearance);
25+
}
26+
});
27+
2128
const logoutUser = useCallback(() => {
2229
logout();
2330
history.goBack();

0 commit comments

Comments
 (0)