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.

12345678910111213141516171819202122232425262728293031323334353637383940
  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. NSString *appName = [(NSString *)([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]) stringByReplacingOccurrencesOfString:@"Helper" withString:@""];
  15. NSArray *running = [[NSWorkspace sharedWorkspace] runningApplications];
  16. for (NSRunningApplication *app in running) {
  17. if ([[app bundleIdentifier] isEqualToString:appName]) {
  18. alreadyRunning = YES;
  19. }
  20. }
  21. if (!alreadyRunning) {
  22. NSString *path = [[NSBundle mainBundle] bundlePath];
  23. NSArray *p = [path pathComponents];
  24. NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:p];
  25. [pathComponents removeLastObject];
  26. [pathComponents removeLastObject];
  27. [pathComponents removeLastObject];
  28. [pathComponents addObject:@"MacOS"];
  29. [pathComponents addObject:@"BaconBar"];
  30. NSString *newPath = [NSString pathWithComponents:pathComponents];
  31. [[NSWorkspace sharedWorkspace] launchApplication:newPath];
  32. }
  33. [NSApp terminate:nil];
  34. }
  35. @end