|
|
|
@ -25,6 +25,8 @@ |
|
|
|
#import "SPMediaKeyTap.h" |
|
|
|
#import "SPInvocationGrabbing.h" |
|
|
|
|
|
|
|
NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys"; |
|
|
|
|
|
|
|
@interface SPMediaKeyTap () { |
|
|
|
EventHandlerRef _app_switching_ref; |
|
|
|
EventHandlerRef _app_terminating_ref; |
|
|
|
@ -162,42 +164,47 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers |
|
|
|
+ (NSArray*)mediaKeyUserBundleIdentifiers |
|
|
|
{ |
|
|
|
return [NSArray arrayWithObjects: |
|
|
|
static NSArray *bundleIdentifiers; |
|
|
|
static dispatch_once_t onceToken; |
|
|
|
dispatch_once(&onceToken, ^{ |
|
|
|
bundleIdentifiers = @[ |
|
|
|
[[NSBundle mainBundle] bundleIdentifier], // your app |
|
|
|
@"com.spotify.client", |
|
|
|
@"com.apple.iTunes", |
|
|
|
@"com.apple.QuickTimePlayerX", |
|
|
|
@"com.apple.quicktimeplayer", |
|
|
|
@"com.apple.iWork.Keynote", |
|
|
|
@"com.apple.iPhoto", |
|
|
|
@"org.videolan.vlc", |
|
|
|
@"com.apple.Aperture", |
|
|
|
@"com.plexsquared.Plex", |
|
|
|
@"com.soundcloud.desktop", |
|
|
|
@"org.niltsh.MPlayerX", |
|
|
|
@"com.ilabs.PandorasHelper", |
|
|
|
@"com.mahasoftware.pandabar", |
|
|
|
@"com.bitcartel.pandorajam", |
|
|
|
@"org.clementine-player.clementine", |
|
|
|
@"fm.last.Last.fm", |
|
|
|
@"fm.last.Scrobbler", |
|
|
|
@"com.beatport.BeatportPro", |
|
|
|
@"com.Timenut.SongKey", |
|
|
|
@"com.macromedia.fireworks", // the tap messes up their mouse input |
|
|
|
@"at.justp.Theremin", |
|
|
|
@"ru.ya.themblsha.YandexMusic", |
|
|
|
@"com.jriver.MediaCenter18", |
|
|
|
@"com.jriver.MediaCenter19", |
|
|
|
@"com.jriver.MediaCenter20", |
|
|
|
@"co.rackit.mate", |
|
|
|
@"com.ttitt.b-music", |
|
|
|
@"com.beardedspice.BeardedSpice", |
|
|
|
@"com.plug.Plug", |
|
|
|
@"com.netease.163music", |
|
|
|
nil |
|
|
|
]; |
|
|
|
@"com.spotify.client", |
|
|
|
@"com.apple.iTunes", |
|
|
|
@"com.apple.QuickTimePlayerX", |
|
|
|
@"com.apple.quicktimeplayer", |
|
|
|
@"com.apple.iWork.Keynote", |
|
|
|
@"com.apple.iPhoto", |
|
|
|
@"org.videolan.vlc", |
|
|
|
@"com.apple.Aperture", |
|
|
|
@"com.plexsquared.Plex", |
|
|
|
@"com.soundcloud.desktop", |
|
|
|
@"org.niltsh.MPlayerX", |
|
|
|
@"com.ilabs.PandorasHelper", |
|
|
|
@"com.mahasoftware.pandabar", |
|
|
|
@"com.bitcartel.pandorajam", |
|
|
|
@"org.clementine-player.clementine", |
|
|
|
@"fm.last.Last.fm", |
|
|
|
@"fm.last.Scrobbler", |
|
|
|
@"com.beatport.BeatportPro", |
|
|
|
@"com.Timenut.SongKey", |
|
|
|
@"com.macromedia.fireworks", // the tap messes up their mouse input |
|
|
|
@"at.justp.Theremin", |
|
|
|
@"ru.ya.themblsha.YandexMusic", |
|
|
|
@"com.jriver.MediaCenter18", |
|
|
|
@"com.jriver.MediaCenter19", |
|
|
|
@"com.jriver.MediaCenter20", |
|
|
|
@"co.rackit.mate", |
|
|
|
@"com.ttitt.b-music", |
|
|
|
@"com.beardedspice.BeardedSpice", |
|
|
|
@"com.plug.Plug", |
|
|
|
@"com.netease.163music", |
|
|
|
]; |
|
|
|
}); |
|
|
|
|
|
|
|
return bundleIdentifiers; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -295,11 +302,6 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv |
|
|
|
|
|
|
|
#pragma mark Task switching callbacks |
|
|
|
|
|
|
|
NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey = @"SPApplicationsNeedingMediaKeys"; |
|
|
|
NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)mediaKeyAppListChanged |
|
|
|
{ |
|
|
|
if([_mediaKeyAppList count] == 0) return; |
|
|
|
@ -335,8 +337,8 @@ NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys"; |
|
|
|
); |
|
|
|
NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey]; |
|
|
|
|
|
|
|
NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey]; |
|
|
|
if(![whitelistIdentifiers containsObject:bundleIdentifier]) return; |
|
|
|
if (![[SPMediaKeyTap mediaKeyUserBundleIdentifiers] containsObject:bundleIdentifier]) |
|
|
|
return; |
|
|
|
|
|
|
|
[_mediaKeyAppList removeObject:psnv]; |
|
|
|
[_mediaKeyAppList insertObject:psnv atIndex:0]; |
|
|
|
|