Skip to content

Instantly share code, notes, and snippets.

@wouterverweirder
Created February 16, 2017 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wouterverweirder/c704dcc6245e0a4926a19e21a7658e94 to your computer and use it in GitHub Desktop.
Save wouterverweirder/c704dcc6245e0a4926a19e21a7658e94 to your computer and use it in GitHub Desktop.
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