Skip to content

Instantly share code, notes, and snippets.

@bahamas10
Created May 2, 2014 21:04
Show Gist options
  • Select an option

  • Save bahamas10/48e49f5de71f016e4759 to your computer and use it in GitHub Desktop.

Select an option

Save bahamas10/48e49f5de71f016e4759 to your computer and use it in GitHub Desktop.
active application notification in os x
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSNotificationCenter *center = NSWorkspace.sharedWorkspace.notificationCenter;
[center addObserver:self
selector:@selector(callback:)
name:NSWorkspaceDidActivateApplicationNotification
object:nil];
}
- (void)callback:(NSNotification *)d
{
NSRunningApplication *app = d.userInfo[NSWorkspaceApplicationKey];
NSLog(@"%@", app.localizedName);
}
/**
2014-05-02 14:04:22.150 AppFocus[28162:303] Alfred
2014-05-02 14:04:23.369 AppFocus[28162:303] Terminal
2014-05-02 14:04:23.379 AppFocus[28162:303] Google Chrome
2014-05-02 14:04:45.506 AppFocus[28162:303] Terminal
2014-05-02 14:04:46.943 AppFocus[28162:303] Xcode
*/
@papertigers
Copy link
Copy Markdown

This is sick! Im gonna port Viridian to android this weekend.

@bahamas10
Copy link
Copy Markdown
Author

https://github.com/bahamas10/app-focus made into a standalone app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment