hammerspoon2-docs
    Preparing search index...

    Class HSMenuBarItem

    Object representing a macOS system menu bar item. Create instances with hs.menubar.create().

    Index

    Constructors

    Properties

    title: string | null

    Get or set the menu item's title.

    Methods

    • Remove this item from the menu bar. The item is retained and can be shown again with show().

      Returns void

    • Check if this item is currently visible in the menu bar.

      Returns boolean

      true if the item is visible in the menu bar

    • Set a callback invoked when the item is clicked (only fires when no menu is set)

      Parameters

      • fn: (() => void) | null

        A function to call on click, or null to remove the callback

      Returns void

    • Set the icon displayed in the menu bar

      Parameters

      • image: HSImage | null

        An HSImage object, or null to remove the icon

      Returns void

    • Set the menu for this item. Pass an array of menu item objects for a static menu, or a function that returns an array for a dynamic menu populated each time it opens.

      Parameters

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

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

      Returns void

    • Set the tooltip shown when hovering over the menu bar item

      Parameters

      • tooltip: string | null

        Tooltip text, or null to remove the tooltip

      Returns void

    • Show this item in the menu bar.

      Returns void