AppLauncher v0.4.1

A Hammerspoon Spoon that binds hotkeys to launch or focus apps, open files or URLs, or run functions.

Overview

Actions run straight from the hotkey callback. If one is still running after a short delay, a ● appears in the menu bar until it finishes. Each press also logs when the key was received and how long the action took, so slow hotkeys are easy to spot in the Console.

Download: https://github.com/hugoh/AppLauncher.spoon/releases/latest

Variables

AppLauncher.notify Variable #

Show Hammerspoon's hotkey alert with the mapping's name on each press (default: false).

AppLauncher.indicatorDelay Variable #

Seconds an action may run before a ● appears in the menu bar, or false to never show it (default: 0.2). The indicator can only appear while Hammerspoon's main thread is free, e.g. while an app launches or an async function waits; work that blocks the main thread shows nothing.

AppLauncher.actionTimeout Variable #

Seconds after which an action that hasn't finished (e.g. an async function that never calls done) stops counting as running, so the indicator can't get stuck; false to wait forever (default: 5).

AppLauncher.logElapsedAbove Variable #

Seconds an action must take before its elapsed time is logged, 0 to always log it, or false to never log it (default: 0.1).

Methods

AppLauncher:init() Method #

Called automatically by hs.loadSpoon(). Logs the loaded version.

AppLauncher:configure(opts) → AppLauncher Method #

Sets one or more of AppLauncher's variables (notify, indicatorDelay, actionTimeout, logElapsedAbove) from a table. Call it before registerMappings, since notify is read when hotkeys are bound.

  • opts - a table with any of the variable names above as keys
  • The AppLauncher object, for method chaining
AppLauncher:registerMappings(mods, mappings) → AppLauncher Method #

Binds a hotkey for each mapping.

  • mods - a table of modifier keys shared by all mappings, e.g. { "ctrl", "alt", "cmd" }
  • mappings - a list of tables, each with a key and one action:
    • app - name of an app to focus, launching it if needed; set forceOpen = true to always go through hs.application.launchOrFocus; activating brings all of the app's windows forward (a running app with no window goes through launchOrFocus so one reopens), and raiseWindows = true also raises each window individually (off by default: it can take ~150 ms per window in some apps, e.g. Electron ones, blocking Hammerspoon meanwhile)
    • open - a file, folder or URL passed to /usr/bin/open
    • func - a function to call; with async = true it receives a done callback to call when finished; the action counts as running until then
    • label - optional name for a func mapping, used in logs and alerts
  • The AppLauncher object, for method chaining