hs
ModuleProperties
hs.onRelaunch
function | null
Called when Hammerspoon 2 is launched again while it's already
running (e.g. from Finder, Spotlight or `open -a`), or when its Dock icon is clicked, or null
to remove it. It's only called when Settings → Advanced → "When launched while running" is
set to "Call hs.onRelaunch". If it's set to that and no callback is set (for example because
your config failed to load), the Console is shown instead, so you can always get back to it.
hs.onOpenFile
function | null
Called when a file or folder is opened with Hammerspoon 2,
e.g. by dropping it on the Dock icon, choosing Hammerspoon 2 from Finder's "Open With" menu,
or `open -a "Hammerspoon 2" file.txt`, or null to remove it. It's called once for each item,
with its path. Spoons (`.spoon2` files) are installed rather than passed to it, unless
"Install Spoons when opened" is turned off in the Advanced tab of Settings.
Items opened before your config has loaded (for example, the one that launched
Hammerspoon 2) are passed to it once your config has loaded.
Methods
hs.reload() -> None
Destroy the current JavaScript runtime and start a new one, loading all configuration from disk again
Declaration
hs.reload() -> None
Returns
None
Example
hs.reload()
hs.collectGarbage() -> None
Force garbage collection of JavaScript objects that no longer have any references
Declaration
hs.collectGarbage() -> None
Returns
None
Notes
This uses private macOS API
Example
hs.collectGarbage()
hs.activeObjects() -> any[]
Get every object that is currently active: running tasks, scheduled timers, started
watchers and so on. An active object keeps running, and its callbacks keep being called,
until it finishes or you stop it, whether or not you kept a reference to it. Use this to
find something you started and lost track of.
Declaration
hs.activeObjects() -> any[]
Returns
any[]
The active objects
Example
hs.activeObjects().forEach(obj => console.log(obj.toString()))
hs.openConsole() -> None
Open the Hammerspoon Console window
Declaration
hs.openConsole() -> None
Returns
None
Example
hs.openConsole()
hs.closeConsole() -> None
Close the Hammerspoon Console window
Declaration
hs.closeConsole() -> None
Returns
None
Example
hs.closeConsole()
hs.clearConsole() -> None
Clear the Hammerspoon Console log
Declaration
hs.clearConsole() -> None
Returns
None
Example
hs.clearConsole()