docs » 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

API Documentation

Constants

activated
Signature hs.application.watcher.activated
Type Constant
Description An application has been activated (i.e. given keyboard/mouse focus)
Source extensions/application/watcher.m
deactivated
Signature hs.application.watcher.deactivated
Type Constant
Description An application has been deactivated (i.e. lost keyboard/mouse focus)
Source extensions/application/watcher.m
hidden
Signature hs.application.watcher.hidden
Type Constant
Description An application has been hidden
Source extensions/application/watcher.m
launched
Signature hs.application.watcher.launched
Type Constant
Description An application has been launched
Source extensions/application/watcher.m
launching
Signature hs.application.watcher.launching
Type Constant
Description An application is in the process of being launched
Source extensions/application/watcher.m
terminated
Signature hs.application.watcher.terminated
Type Constant
Description An application has been terminated
Source extensions/application/watcher.m
unhidden
Signature hs.application.watcher.unhidden
Type Constant
Description An application has been unhidden
Source extensions/application/watcher.m

Constructors

new
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
Source extensions/application/watcher.m

Methods

start
Signature hs.application.watcher:start()
Type Method
Description Starts the application watcher
Parameters
  • None
Returns
  • The hs.application.watcher object
Source extensions/application/watcher.m
stop
Signature hs.application.watcher:stop()
Type Method
Description Stops the application watcher
Parameters
  • None
Returns
  • The hs.application.watcher object
Source extensions/application/watcher.m