API Docs

Module for customising Hammerspoon's own Dock icon.

The Dock icon is only shown when the "Show in" setting in Hammerspoon's Settings includes the Dock.

Adding items to the Dock icon's menu

hs.dockicon.setMenu([
    { title: "Reload config", fn: () => hs.reload() },
    { title: "-" },
    { title: "Open Console", fn: () => hs.openConsole() }
])

Properties

This module has no properties.

Methods

hs.dockicon.setMenu(menuOrFn) -> None

Set extra items for the menu shown when the Dock icon is right-clicked (or Control-clicked, or held). The items appear above the Dock's own items (Options, Show All Windows, Hide and Quit). Pass an array of menu item objects for a static menu, or a function that returns an array for a menu populated each time it opens. The function receives one argument: the modifier keys held when the menu opened, in the same form as `hs.eventtap.currentModifiers()`. The menu is removed when the config is reloaded.
hs.dockicon.setMenu(menuOrFn) -> None
Name Type Description
menuOrFn JSValue Array of menu item objects, a function returning such an array, or null to remove the extra items
None
hs.dockicon.setMenu([
    { title: "Reload config", fn: () => hs.reload() },
    { title: "-" },
    { title: "Layouts", menu: [
        { title: "Coding", fn: () => console.log("coding") },
        { title: "Writing", fn: () => console.log("writing") }
    ] }
])

// Rebuilt every time the menu opens
hs.dockicon.setMenu((modifiers) => [
    { title: "Opened at " + new Date().toLocaleTimeString(), disabled: true },
    ...(modifiers.includes("alt") ? [{ title: "Advanced", fn: () => console.log("advanced") }] : [])
])

// Remove the extra items
hs.dockicon.setMenu(null)