#hs.application.watcher

Watch for application launch/terminate events

This module is based primarily on code from the previous incarnation of Mjolnir by Markus Engelbrecht and Steven Degutis.


#API Overview

Constants - Useful values which cannot be changed

Constructors - API calls which return an object, typically one that offers API methods

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Constants

Signaturehs.application.watcher.activated
TypeConstant
DescriptionAn application has been activated (i.e. given keyboard/mouse focus)
NotesNone
Sourceextensions/application/libapplication_watcher.m line 33

Signaturehs.application.watcher.deactivated
TypeConstant
DescriptionAn application has been deactivated (i.e. lost keyboard/mouse focus)
NotesNone
Sourceextensions/application/libapplication_watcher.m line 37

Signaturehs.application.watcher.hidden
TypeConstant
DescriptionAn application has been hidden
NotesNone
Sourceextensions/application/libapplication_watcher.m line 25

Signaturehs.application.watcher.launched
TypeConstant
DescriptionAn application has been launched
NotesNone
Sourceextensions/application/libapplication_watcher.m line 17

Signaturehs.application.watcher.launching
TypeConstant
DescriptionAn application is in the process of being launched
NotesNone
Sourceextensions/application/libapplication_watcher.m line 13

Signaturehs.application.watcher.terminated
TypeConstant
DescriptionAn application has been terminated
NotesNone
Sourceextensions/application/libapplication_watcher.m line 21

Signaturehs.application.watcher.unhidden
TypeConstant
DescriptionAn application has been unhidden
NotesNone
Sourceextensions/application/libapplication_watcher.m line 29

#Constructors

| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | hs.application.watcher.new(fn) -> watcher | | Type | Constructor | | Description | Creates an application event watcher | | Parameters |

  • fn - A function that will be called when application events happen. It should accept three parameters: A string containing the name of the application An event type (see the constants defined above) An hs.application object representing the application, or nil if the application couldn't be found
| | Returns |
  • An hs.application.watcher object
| | Notes |
  • If the function is called with an event type of hs.application.watcher.terminated then the application name parameter will be nil and the hs.application parameter, will only be useful for getting the UNIX process ID (i.e. the PID) of the application
| | Examples | None | | Source | extensions/application/libapplication_watcher.m line 142 |


#Methods

Signaturehs.application.watcher:start()
TypeMethod
DescriptionStarts the application watcher
Parameters
  • None
Returns
  • The hs.application.watcher object
NotesNone
ExamplesNone
Sourceextensions/application/libapplication_watcher.m line 224

Signaturehs.application.watcher:stop()
TypeMethod
DescriptionStops the application watcher
Parameters
  • None
Returns
  • The hs.application.watcher object
NotesNone
ExamplesNone
Sourceextensions/application/libapplication_watcher.m line 247