Bypass sending notifications to Growl if Last.fm is enabled and running, as Last.fm has its own display notifications
parent
2655f22b7d
commit
9d6f583eff
|
@ -53,6 +53,7 @@
|
||||||
if (NO == [pe error]) {
|
if (NO == [pe error]) {
|
||||||
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
|
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
|
||||||
[scrobbler start:pe];
|
[scrobbler start:pe];
|
||||||
|
if ([AudioScrobbler isRunning]) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: We don't want to send a growl notification on resume.
|
// Note: We don't want to send a growl notification on resume.
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
semaphore_t _semaphore;
|
semaphore_t _semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (BOOL) isRunning;
|
||||||
|
|
||||||
- (void) start:(PlaylistEntry *)pe;
|
- (void) start:(PlaylistEntry *)pe;
|
||||||
- (void) stop;
|
- (void) stop;
|
||||||
- (void) pause;
|
- (void) pause;
|
||||||
|
|
|
@ -67,6 +67,20 @@ escapeForLastFM(NSString *string)
|
||||||
|
|
||||||
@implementation AudioScrobbler
|
@implementation AudioScrobbler
|
||||||
|
|
||||||
|
+ (BOOL) isRunning
|
||||||
|
{
|
||||||
|
NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications];
|
||||||
|
BOOL running = NO;
|
||||||
|
for(NSRunningApplication *app in launchedApps) {
|
||||||
|
if([[app bundleIdentifier] isEqualToString:@"fm.last.Last.fm"] ||
|
||||||
|
[[app bundleIdentifier] isEqualToString:@"fm.last.Scrobbler"]) {
|
||||||
|
running = YES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if((self = [super init])) {
|
if((self = [super init])) {
|
||||||
|
@ -74,18 +88,8 @@ escapeForLastFM(NSString *string)
|
||||||
_pluginID = @"cog";
|
_pluginID = @"cog";
|
||||||
|
|
||||||
if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"]) {
|
if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"]) {
|
||||||
|
|
||||||
NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications];
|
if(![AudioScrobbler isRunning]) {
|
||||||
BOOL running = NO;
|
|
||||||
for(NSRunningApplication *app in launchedApps) {
|
|
||||||
if([[app bundleIdentifier] isEqualToString:@"fm.last.Last.fm"] ||
|
|
||||||
[[app bundleIdentifier] isEqualToString:@"fm.last.Scrobbler"]) {
|
|
||||||
running = YES;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!running) {
|
|
||||||
[[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"];
|
[[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue