Merge pull request #74 from hyperspacedev/system-preferences-73

Run macOS theme changes only when on macOS
This commit is contained in:
Marquis Kurt 2019-09-15 16:12:13 -04:00 committed by GitHub
commit 6fa5cd9cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -24,6 +24,7 @@ protocol.registerSchemesAsPrivileged([
/**
* Determine whether the desktop app is on macOS
* - Returns: Boolean of whether platform is Darwin
*/
function darwin() {
return process.platform === "darwin";
@ -149,17 +150,18 @@ function createWindow() {
// Load the main app and open the index page.
mainWindow.loadURL("hyperspace://hyperspace/app/");
// Watch for a change in macOS's dark mode and reload the window to apply changes
systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => {
if (darwin()) {
systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => {
if (mainWindow != null) {
console.log(`Dark mode: ${systemPreferences.isDarkMode()}`)
if (!catalina()) {
mainWindow.setVibrancy(systemPreferences.isDarkMode()? "ultra-dark": "light");
}
mainWindow.webContents.reload();
}
})
}
// Delete the window when closed
mainWindow.on('closed', () => {