docs » EnsureApp

Utility for providing fast and guaranteed access to app windows during macros.

Download: https://github.com/adammillerio/Spoons/raw/main/Spoons/EnsureApp.spoon.zip

README with Example Usage: README.md

API Overview

API Documentation

Constants

maximize
Signature EnsureApp.action.maximize
Type Constant
Description

Maximize the application on the current space if it is not maximized already.

Source Source/EnsureApp.spoon/init.lua line 29
move
Signature EnsureApp.action.move
Type Constant
Description

Move the window to appear under the provided frame as if it were a menu. This

Source Source/EnsureApp.spoon/init.lua line 23
none
Signature EnsureApp.action.none
Type Constant
Description

No-op, will do no action other than moving window to the space and focusing

Source Source/EnsureApp.spoon/init.lua line 33

Variables

appNamesSet
Signature EnsureApp.appNamesSet
Type Variable
Description

Table with "Set" of all app names configured for EnsureApp.

Source Source/EnsureApp.spoon/init.lua line 63
apps
Signature EnsureApp.apps
Type Variable
Description

Table containing each application's name and it's desired configuration. The

Source Source/EnsureApp.spoon/init.lua line 42
defaultAppConfig
Signature EnsureApp.defaultAppConfig
Type Variable
Description

Table containing the default configuration to be used for any app that is not

Source Source/EnsureApp.spoon/init.lua line 56
logger
Signature EnsureApp.logger
Type Variable
Description

Logger object used within the Spoon. Can be accessed to set the default log

Source Source/EnsureApp.spoon/init.lua line 68
logLevel
Signature EnsureApp.logLevel
Type Variable
Description

EnsureApp specific log level override, see hs.logger.setLogLevel for options.

Source Source/EnsureApp.spoon/init.lua line 74
windowOpenTimer
Signature EnsureApp.windowOpenTimer
Type Variable
Description

hs.timer for moving an app's first window after being opened via EnsureApp.

Source Source/EnsureApp.spoon/init.lua line 79

Methods

ensureApp
Signature EnsureApp:ensureApp(appName[, actionConfig])
Type Method
Description

Ensure the existence of a window from appName in the current Space.

Parameters
  • appName - Name of the application to ensure.
  • actionConfig - Optional actionConfig table with action-specific information.
    • moveMenuBar- hs.menubar to move under with action=move.
Returns
  • None
Notes
  • The application name must be one recognized by macOS. hs.applications.find way to discover this.
  • The default action is to move the most recently accessed window in any space corresponding to this application to the current space and focus it.
    • This can be configured with defaultAppConfig.
  • Refer to EnsureApp.apps for information on how to add additional app-specific configurations like space precedence.
Source Source/EnsureApp.spoon/init.lua line 275
ensureAppCallback
Signature EnsureApp:ensureAppCallback(appName[, actionConfig])
Type Method
Description

(Callback) Ensure the existence of a window from appName in the current Space.

Parameters
  • appName - Name of the application to ensure.
  • actionConfig - Optional actionConfig table with action-specific information.
    • moveMenuBar- hs.menubar to move under with action=move.
Returns
  • None
Notes
  • This is a utility class for mapping app ensures to things like menu bars.
  • Refer to EnsureApp.apps for information on how to configure apps.
Source Source/EnsureApp.spoon/init.lua line 256
getAppEnsured
Signature EnsureApp:getAppEnsured(app)
Type Method
Description

Returns whether or not app name is configured for EnsureApp.

Parameters
  • app - App name to check.
Returns
  • A boolean representing whether or not the app is configured for EnsureApp.
Source Source/EnsureApp.spoon/init.lua line 457
getAppNames
Signature EnsureApp:getAppNames([spaceID])
Type Method
Description

Get a list of all app names currently configured in EnsureApps.

Parameters
  • spaceID - Optional space ID. If provided, WindowCache will be queried to find apps present in the provided space. These will then be placed at the beginning of the list before the rest of the configured apps are filled. This is useful for things like Lightspot.spoon.
Returns
  • A table representing the names of all configured app names, with recent apps in the current space being prioritized if spaceID is provided.
Notes
  • WindowCache window access history does not persist through Hammerspoon reloads.
Source Source/EnsureApp.spoon/init.lua line 397
getAppNamesForSpace
Signature EnsureApp:getAppNamesForSpace(spaceID)
Type Method
Description

Given a spaceID, return the name of all configured apps present in the space.

Parameters
  • spaceID - ID of an hs.space to retrieve ensured app names for.
Returns
  • A table representing the names of all ensured apps currently present in the space, ordered by most recent first.
Source Source/EnsureApp.spoon/init.lua line 434
init
Signature EnsureApp:init()
Type Method
Description

Spoon initializer method for EnsureApp.

Parameters
  • None
Returns
  • None
Source Source/EnsureApp.spoon/init.lua line 85
start
Signature EnsureApp:start()
Type Method
Description

Spoon start method for EnsureApp.

Parameters
  • None
Returns
  • None
Source Source/EnsureApp.spoon/init.lua line 474
stop
Signature EnsureApp:stop()
Type Method
Description

Spoon stop method for EnsureApp.

Parameters
  • None
Returns
  • None
Source Source/EnsureApp.spoon/init.lua line 495