// // AppDelegate.m // BaconBarHelper // // Created by Thomas Buck on 28.12.13. // Copyright (c) 2013 xythobuz. All rights reserved. // #import "AppDelegate.h" @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Check if main app is already running; if yes, do nothing and terminate helper app BOOL alreadyRunning = NO; NSArray *running = [[NSWorkspace sharedWorkspace] runningApplications]; for (NSRunningApplication *app in running) { if ([[app bundleIdentifier] isEqualToString:@"xythobuz.BaconBar"]) { alreadyRunning = YES; } } if (!alreadyRunning) { NSString *path = [[NSBundle mainBundle] bundlePath]; NSArray *p = [path pathComponents]; NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:p]; [pathComponents removeLastObject]; [pathComponents removeLastObject]; [pathComponents removeLastObject]; [pathComponents addObject:@"MacOS"]; [pathComponents addObject:@"BaconBar"]; NSString *newPath = [NSString pathWithComponents:pathComponents]; [[NSWorkspace sharedWorkspace] launchApplication:newPath]; } [NSApp terminate:nil]; } @end