Skip to content

Commit

Permalink
main: 'auto' theme variety leveraging electron's nativeTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Nov 21, 2020
1 parent c0f2e8a commit f1448a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'path';
import { app, BrowserWindow, ipcMain, Menu } from 'electron';
import { app, BrowserWindow, ipcMain, Menu, nativeTheme } from 'electron';

import { IsDev, IsDarwin, MainURL, LoginURL } from './util/constants';
import * as Settings from './settings';
Expand Down Expand Up @@ -32,6 +32,10 @@ app.commandLine.appendSwitch('disable-features', 'HardwareMediaKeyHandling,Media
* @returns {import('electron').BrowserWindow}
*/
function createMainWindow(settings, url = MainURL) {
const windowBackgroundType = settings.themeVariety === 'auto'
? (nativeTheme.shouldUseDarkColors ? 'dark' : 'light')
: settings.themeVariety;

const win = new BrowserWindow({
height: 700,
width: 1000,
Expand All @@ -40,7 +44,7 @@ function createMainWindow(settings, url = MainURL) {
minHeight: 640,
frame: settings.windowBorder,
titleBarStyle: settings.windowBorder ? 'default' : 'hidden',
backgroundColor: MainBkgColor[settings.themeVariety],
backgroundColor: MainBkgColor[windowBackgroundType],
title: Settings.productName,
webPreferences: {
zoomFactor: settings.windowZoom || 1,
Expand Down
2 changes: 1 addition & 1 deletion src/main/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const defaultSettings = {
minimizeOnStartup: false,
themePrimaryColor: '#7e57c2',
themeSecondaryColor: '#ff4081',
themeVariety: 'light',
themeVariety: 'auto',
autoReplacePlaylist: false
};

Expand Down

0 comments on commit f1448a3

Please sign in to comment.