mamburu: Only launch last.fm client if it isn't already running (prevents last.fm client's window from popping up on Cog restarts)

CQTexperiment
Chris Moeller 2013-10-11 05:37:11 -07:00
parent 73524776e7
commit d98b5549d1
1 changed files with 17 additions and 4 deletions

View File

@ -72,10 +72,23 @@ escapeForLastFM(NSString *string)
if((self = [super init])) {
_pluginID = @"cog";
if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"])
[[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"]) {
NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications];
BOOL running = NO;
for(NSRunningApplication *app in launchedApps) {
if([[app bundleIdentifier] isEqualToString:@"fm.last.Last.fm"]) {
running = YES;
break;
}
}
if(!running) {
[[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"];
}
}
_keepProcessingAudioScrobblerCommands = YES;
kern_return_t result = semaphore_create(mach_task_self(), &_semaphore, SYNC_POLICY_FIFO, 0);