Hammerspoon/hammerspoon — pull request #158 by mgee (2014-12-16 17:29:20+00:00)
Title: add hs.application.watcher to watch application events

This implements #57.

`hs.application.watcher.new(fn) -> watcher`
Creates an application watcher that is able to capture application events.
The parameter `fn` has to be a function accepting two parameters. The first parameter passed to
the function is the application name as string and the second parameter is the event type.
The event type parameter can be one of the following values:
```lua
hs.application.watcher.launching -- The application will launch.
hs.application.watcher.launched -- The application has launched.
hs.application.watcher.terminated -- The application terminated.
hs.application.watcher.hidden -- The application was hidden.
hs.application.watcher.unhidden -- The application was unhidden.
hs.application.watcher.activated -- The application was activated.
hs.application.watcher.deactivated -- The application was deactivated.
```

`hs.application.watcher:start()`
Starts the application watcher, making it so `fn` is called each time an application event is triggered.

`hs.application.watcher:stop()`
Stops the application watcher's `fn` from getting called until started again.