Created
February 16, 2017 17:35
-
-
Save wouterverweirder/c704dcc6245e0a4926a19e21a7658e94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const electron = require('electron'); | |
const app = electron.app; | |
const BrowserWindow = electron.BrowserWindow; | |
const path = require('path'); | |
const url = require('url'); | |
let mainWindow; | |
const setNotifactionCenterMode = enabled => { | |
//don't do anything on non-OSX machines | |
if (process.platform !== 'darwin') { | |
return; | |
} | |
const execSync = require('child_process').execSync; | |
if (enabled) { | |
execSync('launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist'); | |
} else { | |
execSync('launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist'); | |
} | |
}; | |
//disable notification center | |
setNotifactionCenterMode(false); | |
app.on('before-quit', () => { | |
//enable notification center on quit | |
setNotifactionCenterMode(true); | |
}); | |
const createWindow = () => { | |
// Create the browser window. | |
mainWindow = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
// fullscreen: true, | |
// kiosk: true, | |
minimizable: false, | |
maximizable: false, | |
}); | |
mainWindow.setContentProtection(true); | |
// and load the index.html of the app. | |
mainWindow.loadURL(url.format({ | |
pathname: path.join(__dirname, 'index.html'), | |
protocol: 'file:', | |
slashes: true | |
})) | |
// Open the DevTools. | |
// mainWindow.webContents.openDevTools() | |
// Emitted when the window is closed. | |
mainWindow.on('closed', () => { | |
mainWindow = null | |
}); | |
}; | |
app.on('ready', createWindow) | |
// Quit when all windows are closed. | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}); | |
app.on('activate', () => { | |
if (mainWindow === null) { | |
createWindow() | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment