{"action":"created","issue":{"url":"https://api.github.com/repos/atom/electron/issues/3145","labels_url":"https://api.github.com/repos/atom/electron/issues/3145/labels{/name}","comments_url":"https://api.github.com/repos/atom/electron/issues/3145/comments","events_url":"https://api.github.com/repos/atom/electron/issues/3145/events","html_url":"https://github.com/atom/electron/pull/3145","id":112209938,"number":3145,"title":"Implement Single-Instance for Windows / Linux","user":{"login":"paulcbetts","id":1396,"avatar_url":"https://avatars.githubusercontent.com/u/1396?v=3","gravatar_id":"","url":"https://api.github.com/users/paulcbetts","html_url":"https://github.com/paulcbetts","followers_url":"https://api.github.com/users/paulcbetts/followers","following_url":"https://api.github.com/users/paulcbetts/following{/other_user}","gists_url":"https://api.github.com/users/paulcbetts/gists{/gist_id}","starred_url":"https://api.github.com/users/paulcbetts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulcbetts/subscriptions","organizations_url":"https://api.github.com/users/paulcbetts/orgs","repos_url":"https://api.github.com/users/paulcbetts/repos","events_url":"https://api.github.com/users/paulcbetts/events{/privacy}","received_events_url":"https://api.github.com/users/paulcbetts/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-19T19:00:14Z","updated_at":"2015-10-22T06:18:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/atom/electron/pulls/3145","html_url":"https://github.com/atom/electron/pull/3145","diff_url":"https://github.com/atom/electron/pull/3145.diff","patch_url":"https://github.com/atom/electron/pull/3145.patch"},"body":"This PR implements a new proposed API on `app` which allows Electron apps on Windows and Linux to be single-instance apps (and receive the command-line parameters from secondary invocations).\r\n\r\n### Proposed API\r\n\r\n```js\r\nimport app from 'app';\r\n\r\napp.on('ready', () => {\r\n  shouldQuit = app.makeSingleInstance((cmdLine) => {\r\n    // TODO: Handle command line from secondary instance\r\n    return true;\r\n  });\r\n\r\n  if (shouldQuit) app.quit(0);\r\n});\r\n```\r\n\r\nWhen apps are invoked as the secondary instance (i.e. an instance is already running), `makeSingleInstance` will send the command-line arguments to the primary instance and exit the app. This means that `makeSingleInstance` should be called as early as possible (i.e. before `ready`), so we'll set it up for that to be possible\r\n\r\n## TODO:\r\n\r\n- [x] Bring the code over from Chrome that implements this\r\n- [x] Make the code compile on Windows\r\n- [x] Make the code compile on Linux\r\n- [x] Wire it up to `app`\r\n- [x] Fix all the TODOs\r\n- [x] Fix crash on OS X / maybe Linux\r\n- [x] Ensure communication window isn't subject to UIPI problems on Win32\r\n- [x] Verify on Linux\r\n- [x] Code Cleanups\r\n- [x] :memo:"},"comment":{"url":"https://api.github.com/repos/atom/electron/issues/comments/150119626","html_url":"https://github.com/atom/electron/pull/3145#issuecomment-150119626","issue_url":"https://api.github.com/repos/atom/electron/issues/3145","id":150119626,"user":{"login":"zcbenz","id":639601,"avatar_url":"https://avatars.githubusercontent.com/u/639601?v=3","gravatar_id":"","url":"https://api.github.com/users/zcbenz","html_url":"https://github.com/zcbenz","followers_url":"https://api.github.com/users/zcbenz/followers","following_url":"https://api.github.com/users/zcbenz/following{/other_user}","gists_url":"https://api.github.com/users/zcbenz/gists{/gist_id}","starred_url":"https://api.github.com/users/zcbenz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcbenz/subscriptions","organizations_url":"https://api.github.com/users/zcbenz/orgs","repos_url":"https://api.github.com/users/zcbenz/repos","events_url":"https://api.github.com/users/zcbenz/events{/privacy}","received_events_url":"https://api.github.com/users/zcbenz/received_events","type":"User","site_admin":true},"created_at":"2015-10-22T06:18:28Z","updated_at":"2015-10-22T06:18:28Z","body":":+1: "}}