feat(dock): Automatically add N1 to the OS X dock upon install

Note - you need to `killall Dock` to see this after it happens
This commit is contained in:
Ben Gotow 2016-10-13 15:01:51 -07:00
parent cb7b3764f5
commit c7a85af843
2 changed files with 14 additions and 3 deletions

View file

@ -20,7 +20,7 @@ export default class WelcomePage extends React.Component {
} }
_onSelfHosting = () => { _onSelfHosting = () => {
OnboardingActions.moveToPage("self-hosting-restrictions") OnboardingActions.moveToPage("self-hosting-restrictions");
} }
_renderContent(isFirstAccount) { _renderContent(isFirstAccount) {

View file

@ -77,7 +77,16 @@ export default class Application extends EventEmitter {
const helper = new DefaultClientHelper(); const helper = new DefaultClientHelper();
helper.registerForURLScheme('nylas'); helper.registerForURLScheme('nylas');
} else { } 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 "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>${appPath.split('.app/')[0]}.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"`);
config.set('addedToDock', true);
}
} }
} }
@ -552,7 +561,9 @@ export default class Application extends EventEmitter {
}) })
ipcMain.on("move-to-applications", () => { ipcMain.on("move-to-applications", () => {
if (process.platform !== "darwin") return; if (process.platform !== "darwin") {
return;
}
const re = /(^.*?\.app)/i; const re = /(^.*?\.app)/i;
const appPath = (re.exec(process.argv[0]) || [])[0]; const appPath = (re.exec(process.argv[0]) || [])[0];
if (!appPath) { if (!appPath) {