aka RedditBar, Mac OS X menu bar reddit client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppDelegate.m 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // AppDelegate.m
  3. // BaconBarHelper
  4. //
  5. // Created by Thomas Buck on 28.12.13.
  6. // Copyright (c) 2013 xythobuz. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. @implementation AppDelegate
  10. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  11. {
  12. // Check if main app is already running; if yes, do nothing and terminate helper app
  13. BOOL alreadyRunning = NO;
  14. NSArray *running = [[NSWorkspace sharedWorkspace] runningApplications];
  15. for (NSRunningApplication *app in running) {
  16. if ([[app bundleIdentifier] isEqualToString:@"xythobuz.BaconBar"]) {
  17. alreadyRunning = YES;
  18. }
  19. }
  20. if (!alreadyRunning) {
  21. NSString *path = [[NSBundle mainBundle] bundlePath];
  22. NSArray *p = [path pathComponents];
  23. NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:p];
  24. [pathComponents removeLastObject];
  25. [pathComponents removeLastObject];
  26. [pathComponents removeLastObject];
  27. [pathComponents addObject:@"MacOS"];
  28. [pathComponents addObject:@"BaconBar"];
  29. NSString *newPath = [NSString pathWithComponents:pathComponents];
  30. [[NSWorkspace sharedWorkspace] launchApplication:newPath];
  31. }
  32. [NSApp terminate:nil];
  33. }
  34. @end