Ah, I figured it out myself. There's a class called NSWorkspace that contains an NSNotificationCenter that you can add observers too. I added an observer for the name "NSWorkspaceDidLaunchApplicationNotification" and this seems to do the trick.
source
share