Skip to content

Instantly share code, notes, and snippets.

@darwin
Created October 29, 2014 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darwin/b8cba040c60f6c192a93 to your computer and use it in GitHub Desktop.
Save darwin/b8cba040c60f6c192a93 to your computer and use it in GitHub Desktop.
+ (void)install {
[self acquireLock];
AUTO_LOG();
[self launchCrashWatcher];
[self initDebugSubsystems];
[self sanitizeDefaults];
if (!hasTweak(TTDoNotTouchWindowsOnStartKey)) {
if (hasTweak(TTCloseWindowsOnStartKey)) {
LOG(@"closing existing windows because of TTCloseWindowsOnStartKey");
[self closeExistingWindows];
} else {
NSTimeInterval secondsSinceTerminalLaunch = fabs([[[NSRunningApplication currentApplication] launchDate] timeIntervalSinceNow]);
if (secondsSinceTerminalLaunch == 0.0) {
// If Terminal is launched via launchd, -[NSRunningApplication launchDate] returns nil
// so to get a valid launch date we use GetProcessInfo() instead
ProcessInfoRec info;
info.processInfoLength = sizeof(ProcessInfoRec);
info.processName = nil;
info.processAppRef = nil;
ProcessSerialNumber psn = {0, kCurrentProcess};
if (GetProcessInformation(&psn, &info) == noErr) {
secondsSinceTerminalLaunch = CFAbsoluteTimeGetCurrent() - (CFAbsoluteTime)info.processLaunchDate;
}
}
if ((secondsSinceTerminalLaunch > 0.0) && (secondsSinceTerminalLaunch < CloseWindowsOnStartTimeout)) {
LOG(@"closing existing windows because Terminal process is fresh");
[self closeExistingWindows];
}
}
}
[self loadPreferences];
[self loadFeatures];
DCHECK(!gTotalTerminal);
gTotalTerminal = [[TotalTerminal alloc] init];
if (![[NSUserDefaults standardUserDefaults] boolForKey:TTDoNotOpenVisorDuringStartup]) {
[TOTALTERMINAL buildVisor];
}
LOG(@"======== finished booting ========");
booting = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment