From c7a85af843c37a75a0b778970c33057a6e64a893 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 13 Oct 2016 15:01:51 -0700 Subject: [PATCH] feat(dock): Automatically add N1 to the OS X dock upon install Note - you need to `killall Dock` to see this after it happens --- internal_packages/onboarding/lib/page-welcome.jsx | 2 +- src/browser/application.es6 | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal_packages/onboarding/lib/page-welcome.jsx b/internal_packages/onboarding/lib/page-welcome.jsx index 368dfae61..8097c63d2 100644 --- a/internal_packages/onboarding/lib/page-welcome.jsx +++ b/internal_packages/onboarding/lib/page-welcome.jsx @@ -20,7 +20,7 @@ export default class WelcomePage extends React.Component { } _onSelfHosting = () => { - OnboardingActions.moveToPage("self-hosting-restrictions") + OnboardingActions.moveToPage("self-hosting-restrictions"); } _renderContent(isFirstAccount) { diff --git a/src/browser/application.es6 b/src/browser/application.es6 index 667d5d984..d6240d435 100644 --- a/src/browser/application.es6 +++ b/src/browser/application.es6 @@ -77,7 +77,16 @@ export default class Application extends EventEmitter { const helper = new DefaultClientHelper(); helper.registerForURLScheme('nylas'); } else { - app.setAsDefaultProtocolClient('nylas') + app.setAsDefaultProtocolClient('nylas'); + } + + if (process.platform === 'darwin') { + const addedToDock = config.get('addedToDock'); + const appPath = process.argv[0]; + if (!addedToDock && appPath.includes('/Applications/') && appPath.includes('.app/')) { + proc.exec(`defaults write com.apple.dock persistent-apps -array-add "tile-datafile-data_CFURLString${appPath.split('.app/')[0]}.app/_CFURLStringType0"`); + config.set('addedToDock', true); + } } } @@ -552,7 +561,9 @@ export default class Application extends EventEmitter { }) ipcMain.on("move-to-applications", () => { - if (process.platform !== "darwin") return; + if (process.platform !== "darwin") { + return; + } const re = /(^.*?\.app)/i; const appPath = (re.exec(process.argv[0]) || [])[0]; if (!appPath) {