faster startup on macOS

This commit is contained in:
Eugene Pankov 2021-08-19 23:29:44 +02:00
parent 60046da4b3
commit 1992d99556
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
2 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import { app, ipcMain, Menu, Tray, shell, screen, globalShortcut, MenuItemConstructorOptions } from 'electron'
import * as promiseIpc from 'electron-promise-ipc'
import * as remote from '@electron/remote/main'
import { exec } from 'mz/child_process'
import * as path from 'path'
import * as fs from 'fs'
import { Subject, throttleTime } from 'rxjs'
@ -51,6 +52,10 @@ export class Application {
return pluginManager.uninstall(this.userPluginsPath, name)
})
;(promiseIpc as any).on('get-default-mac-shell', async () => {
return (await exec(`/usr/bin/dscl . -read /Users/${process.env.LOGNAME} UserShell`))[0].toString().split(' ')[1].trim()
})
const configData = loadConfig()
if (process.platform === 'linux') {
app.commandLine.appendSwitch('no-sandbox')

View File

@ -1,5 +1,5 @@
import { exec } from 'mz/child_process'
import { Injectable } from '@angular/core'
import promiseIpc, { RendererProcessType } from 'electron-promise-ipc'
import { HostAppService, Platform } from 'tabby-core'
import { ShellProvider, Shell } from '../api'
@ -33,11 +33,11 @@ export class MacOSDefaultShellProvider extends ShellProvider {
if (!this.cachedShell) {
this.cachedShell = await this.getDefaultShell()
}
return this.cachedShell!
return this.cachedShell
}
private async getDefaultShell () {
const shellEntry = (await exec(`/usr/bin/dscl . -read /Users/${process.env.LOGNAME} UserShell`))[0].toString()
return shellEntry.split(' ')[1].trim()
private async getDefaultShell (): Promise<string> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return (promiseIpc as RendererProcessType).send('get-default-mac-shell') as Promise<string>
}
}