How to use the electron-util.darkMode.onChange function in electron-util

To help you get started, we’ve selected a few electron-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / caprine / source / index.ts View on Github external
minHeight: 200,
		alwaysOnTop: config.get('alwaysOnTop'),
		titleBarStyle: 'hiddenInset',
		autoHideMenuBar: config.get('autoHideMenuBar'),
		darkTheme: isDarkMode, // GTK+3
		webPreferences: {
			preload: path.join(__dirname, 'browser.js'),
			contextIsolation: true,
			plugins: true
		}
	});

	setUserLocale();
	initRequestsFiltering();

	darkMode.onChange(() => {
		win.webContents.send('set-dark-mode');
	});

	if (is.macos) {
		win.setSheetOffset(40);
	}

	win.loadURL(mainURL);

	win.on('close', event => {
		if (config.get('quitOnWindowClose')) {
			app.quit();
			return;
		}

		// Workaround for https://github.com/electron/electron/issues/20263
github samuelmeuli / mini-diary / src / renderer / electron / ipcRenderer / listeners.ts View on Github external
dispatchThunk(openOverlay("statistics"));
	});

	// Screen lock
	// Lock diary when screen is locked

	if (is.macos || is.windows) {
		remote.powerMonitor.on("lock-screen", (): void => {
			dispatchThunk(lock());
		});
	}

	// Theme
	// Listen to system theme changes and update the app theme accordingly

	darkMode.onChange((): void => {
		dispatchThunk(setTheme(darkMode.isEnabled ? "dark" : "light"));
	});
}
github hello-efficiency-inc / raven-reader / src / main / index.js View on Github external
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

if (darkMode.isEnabled) {
  if (mainWindow) {
    mainWindow.webContents.send('Dark mode', {
      darkmode: systemPreferences.isDarkMode()
    })
  }
}

darkMode.onChange(() => {
  if (mainWindow) {
    mainWindow.webContents.send('Dark mode', {
      darkmode: darkMode.isEnabled
    })
  }
})

ipcMain.on('article-selected', (event, status) => {
  const menuItemViewBrowser = menu.getMenuItemById('view-browser')
  const menuItemToggleFavourite = menu.getMenuItemById('toggle-favourite')
  const menuItemSaveOffline = menu.getMenuItemById('save-offline')
  const menuItemToggleRead = menu.getMenuItemById('toggle-read')

  menuItemViewBrowser.enabled = true
  menuItemToggleFavourite.enabled = true
  menuItemSaveOffline.enabled = true
github npezza93 / archipelago / app / renderer / about / about.jsx View on Github external
bindListeners() {
    this.addSubscription(
      new Disposable(darkMode.onChange(this.handleDarkModeChange.bind(this)))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )
    ipc.answerMain('close', () => {
      return new Promise(resolve => {
        this.cleanup()
        resolve()
      })
    })
  }
}
github atomiclabs / hyperdex / app / renderer / containers / App.js View on Github external
constructor() {
		super();
		this.views = new Cycled(appViews);
		this.setTheme(this.state.theme);
		this.coinPrices = [];

		darkMode.onChange(() => {
			this.setTheme(this.state.theme);
		});
	}