mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-03 18:57:38 +01:00
Merge pull request #74 from hyperspacedev/system-preferences-73
Run macOS theme changes only when on macOS
This commit is contained in:
commit
6fa5cd9cde
@ -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', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user