hammerspoon2-docs
    Preparing search index...

    Function use

    • Load and configure a Spoon in one step, installing it first if it isn't installed yet - the built-in equivalent of Hammerspoon 1's SpoonInstall:andUse(). If the Spoon is already installed, it's loaded and configured before use() returns, so hs.spoons.<name> can be used on the very next line, and nothing is downloaded. If it isn't installed and source is given, it's installed in the background (see hs.spoons.install()), then loaded and configured, and a notification says so; put anything that needs the Spoon in call hs.spoons.update() for that. each property of config is set on the Spoon's object, exactly as if you'd assigned it yourself, hotkeys is passed to its bindHotkeys() method, fn is called with the Spoon, and finally start() is called if start is true. The Promise rejects with an Error with a code, as hs.spoons.install()'s does, plus ENOTINSTALLED if the Spoon isn't installed and no source was given, or the error thrown by loading or configuring the Spoon.

      Parameters

      • name: string

        The name of the Spoon

      • options: {
            config?: Record<string, any>;
            disable?: boolean;
            fn?: (spoon: Object) => void;
            hotkeys?: "default" | Record<string, any>;
            ref?: string;
            sha256?: string;
            source?: string;
            start?: boolean;
        }

        source, ref and sha256 say where to install the Spoon from, as for hs.spoons.install(). config holds properties to set on the Spoon's object; which ones it reads is up to the Spoon. hotkeys is passed to the Spoon's bindHotkeys(), or "default" passes its defaultHotkeys. fn is called with the Spoon after it's configured. start: true calls its start(). disable: true does nothing at all, which is easier than commenting the call out.

      Returns Promise<Object | null>

      Resolves with the Spoon once it's loaded and configured, or null if disable is true