hammerspoon2-docs
    Preparing search index...

    Function setMenu

    • 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().

      Menu item object keys are the same as for HSMenuBarItem.setMenu():

      • title (string, required): The item label. Use "-" for a separator line.
      • fn (function): Callback invoked when the item is chosen.
      • checked (boolean): If true, a checkmark is shown next to the item.
      • disabled (boolean): If true, the item is greyed out and cannot be chosen.
      • tooltip (string): Tooltip shown when hovering over the item.
      • color (HSColor or hex string): The colour of the item's title text.
      • icon (HSImage): Icon shown to the left of the title.
      • menu (array): Nested array of menu item objects to create a submenu.

      The menu is removed when the config is reloaded.

      Parameters

      • menuOrFn: Record<string, any>[] | ((modifiers: string[]) => Record<string, any>[]) | null

        Array of menu item objects, a function returning such an array, or null to remove the extra items

      Returns void