diff --git a/AudioScrobbler/AudioScrobbler.m b/AudioScrobbler/AudioScrobbler.m index c2129aab2..4783d3a1c 100644 --- a/AudioScrobbler/AudioScrobbler.m +++ b/AudioScrobbler/AudioScrobbler.m @@ -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);