Pref: start automatically on login
This commit is contained in:
@@ -20,6 +20,7 @@ const windows = require('./windows')
|
||||
|
||||
let shouldQuit = false
|
||||
let argv = sliceArgv(process.argv)
|
||||
const hidden = argv.includes('--hidden')
|
||||
|
||||
if (config.IS_PRODUCTION) {
|
||||
// When Electron is running in production mode (packaged app), then run React
|
||||
@@ -67,7 +68,7 @@ function init () {
|
||||
app.on('ready', function () {
|
||||
isReady = true
|
||||
|
||||
windows.main.init()
|
||||
windows.main.init({hidden: hidden})
|
||||
windows.webtorrent.init()
|
||||
menu.init()
|
||||
|
||||
@@ -155,6 +156,8 @@ function processArgv (argv) {
|
||||
dialog.openTorrentFile()
|
||||
} else if (arg === '-u') {
|
||||
dialog.openTorrentAddress()
|
||||
} else if (arg === '--hidden') {
|
||||
// Igonre hidden argument, already being handled
|
||||
} else if (arg.startsWith('-psn')) {
|
||||
// Ignore Mac launchd "process serial number" argument
|
||||
// Issue: https://github.com/feross/webtorrent-desktop/issues/214
|
||||
|
||||
@@ -17,6 +17,7 @@ const shortcuts = require('./shortcuts')
|
||||
const externalPlayer = require('./external-player')
|
||||
const windows = require('./windows')
|
||||
const thumbar = require('./thumbar')
|
||||
const startup = require('./startup')
|
||||
|
||||
// Messages from the main process, to be sent once the WebTorrent process starts
|
||||
const messageQueueMainToWebTorrent = []
|
||||
@@ -102,6 +103,14 @@ function init () {
|
||||
else handlers.uninstall()
|
||||
})
|
||||
|
||||
/**
|
||||
* Startup
|
||||
*/
|
||||
ipc.on('setStartup', (e, flag) => {
|
||||
if (flag) startup.install()
|
||||
else startup.uninstall()
|
||||
})
|
||||
|
||||
/**
|
||||
* Windows: Main
|
||||
*/
|
||||
|
||||
27
src/main/startup.js
Normal file
27
src/main/startup.js
Normal file
@@ -0,0 +1,27 @@
|
||||
module.exports = {
|
||||
install,
|
||||
uninstall
|
||||
}
|
||||
|
||||
const config = require('../config')
|
||||
const AutoLaunch = require('auto-launch')
|
||||
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: config.APP_NAME,
|
||||
isHidden: true
|
||||
})
|
||||
|
||||
function install () {
|
||||
return appLauncher.isEnabled()
|
||||
.then(enabled => {
|
||||
if (enabled) return
|
||||
return appLauncher.enable()
|
||||
})
|
||||
}
|
||||
|
||||
function uninstall () {
|
||||
return appLauncher.isEnabled()
|
||||
.then(enabled => {
|
||||
if (enabled) return appLauncher.disable()
|
||||
})
|
||||
}
|
||||
@@ -26,7 +26,7 @@ const tray = require('../tray')
|
||||
const HEADER_HEIGHT = 38
|
||||
const TORRENT_HEIGHT = 100
|
||||
|
||||
function init () {
|
||||
function init (options) {
|
||||
if (main.win) {
|
||||
return main.win.show()
|
||||
}
|
||||
@@ -40,7 +40,8 @@ function init () {
|
||||
titleBarStyle: 'hidden-inset', // Hide title bar (Mac)
|
||||
useContentSize: true, // Specify web page size without OS chrome
|
||||
width: 500,
|
||||
height: HEADER_HEIGHT + (TORRENT_HEIGHT * 6) // header height + 5 torrents
|
||||
height: HEADER_HEIGHT + (TORRENT_HEIGHT * 6), // header height + 5 torrents
|
||||
show: !options.hidden
|
||||
})
|
||||
|
||||
win.loadURL(config.WINDOW_MAIN)
|
||||
|
||||
Reference in New Issue
Block a user