Electron.js How to minimize/close window to system tray and restore window back from tray?
<p>I want my <a href="https://github.com/electron/electron" rel="noreferrer">Electron.js</a> application to live on system tray and whenever the user wants to do something they can restore from the system tray do something and minimize/close it back to system tray. How do i do that?</p>

<p>I've seen the <code>tray</code> section from the documentation but doesn't help much to achieve what i want. </p>

<p>Here is what i got so far on the <code>main.js</code> file</p>

<pre><code>var application = require('app'),
    BrowserWindow = require('browser-window'),
    Menu = require('menu'), 
    Tray = require('tray'); 
application.on('ready', function () {
    var mainWindow = new BrowserWindow({
        width: 650,
        height: 450,
        'min-width': 500,
        'min-height': 200,
        'accept-first-mouse': true,
        // 'title-bar-style': 'hidden',
        icon:'./icon.png'
    });
    mainWindow.loadUrl('file://' + __dirname + '/src/index.html');
    mainWindow.on('closed', function () {
        mainWindow = null;
    });
    mainWindow.setMenu(null);

    var appIcon = null;
    appIcon = new Tray('./icon-resized.png');
    var contextMenu = Menu.buildFromTemplate([
        { label: 'Restore', type: 'radio' }
    ]);
    appIcon.setToolTip('Electron.js App');
    appIcon.setContextMenu(contextMenu);
});
</code></pre>

<p><strong>UPDATE:</strong></p>

<p>I found this <a href="https://github.com/maxogden/menubar" rel="noreferrer">menubar</a> repo, but it won't work as expected on linux.</p>