aka RedditBar, Mac OS X menu bar reddit client
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AppDelegate.m 1.5KB

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