Files
webtorrent-desktop/main/tray.js
2016-03-29 03:51:15 -07:00

32 lines
754 B
JavaScript

module.exports = {
init
}
var path = require('path')
var electron = require('electron')
var windows = require('./windows')
function init () {
// No tray icon on OSX
if (process.platform === 'darwin') return
var trayIcon = new electron.Tray(path.join(__dirname, '..', 'static', 'WebTorrentSmall.png'))
// On Windows, left click to open the app, right click for context menu
// On Linux, any click (right or left) opens the context menu
trayIcon.on('click', showApp)
var contextMenu = electron.Menu.buildFromTemplate([
{ label: 'Show', click: showApp },
{ label: 'Quit', click: quitApp }
])
trayIcon.setContextMenu(contextMenu)
}
function showApp () {
windows.main.show()
}
function quitApp () {
electron.app.quit()
}