diff --git a/package.json b/package.json index 492e1a2b..d80c3115 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "deep-equal": "^1.0.1", "dlnacasts": "^0.1.0", "drag-drop": "^2.11.0", - "electron-prebuilt": "1.3.1", + "electron-prebuilt": "1.3.2", "fs-extra": "^0.30.0", "hat": "0.0.3", "iso-639-1": "^1.2.1", @@ -87,7 +87,7 @@ "scripts": { "clean": "node ./bin/clean.js", "open-config": "node ./bin/open-config.js", - "package": "rm -rf build/ && jsx --es6module src/ build/ && node ./bin/package.js", + "package": "rimraf build/ && jsx --es6module src/ build/ && node ./bin/package.js", "start": "jsx --es6module src/ build/ && electron .", "test": "standard && node ./bin/check-deps.js", "update-authors": "./bin/update-authors.sh" diff --git a/src/main/index.js b/src/main/index.js index c81517e1..20b5a3fe 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -17,6 +17,7 @@ var menu = require('./menu') var squirrelWin32 = require('./squirrel-win32') var tray = require('./tray') var updater = require('./updater') +var userTasks = require('./user-tasks') var windows = require('./windows') var shouldQuit = false @@ -109,6 +110,7 @@ function delayedInit () { handlers.install() tray.init() updater.init() + userTasks.init() } function onOpen (e, torrentId) { diff --git a/src/main/user-tasks.js b/src/main/user-tasks.js new file mode 100644 index 00000000..47e63f8a --- /dev/null +++ b/src/main/user-tasks.js @@ -0,0 +1,43 @@ +module.exports = { + init +} + +var electron = require('electron') + +var app = electron.app + +/** + * Add a user task menu to the app icon on right-click. (Windows) + */ +function init () { + if (process.platform !== 'win32') return + app.setUserTasks(getUserTasks()) +} + +function getUserTasks () { + return [ + { + arguments: '-n', + title: 'Create New Torrent...', + description: 'Create a new torrent' + }, + { + arguments: '-o', + title: 'Open Torrent File...', + description: 'Open a .torrent file' + }, + { + arguments: '-u', + title: 'Open Torrent Address...', + description: 'Open a torrent from a URL' + } + ].map(getUserTasksItem) +} + +function getUserTasksItem (item) { + return Object.assign(item, { + program: process.execPath, + iconPath: process.execPath, + iconIndex: 0 + }) +}