hammerspoon2-docs
    Preparing search index...

    Class HSUIAlert

    HSUIAlert

    A temporary on-screen notification* Displays a message that automatically fades out after a specified duration. Without an explicit .position(), multiple alerts stack vertically and stay centered as they appear and disappear. With .position(), the alert appears at the given coordinates regardless of other alerts.

    hs.ui.alert("Task completed!")
    .font(HSFont.headline())
    .duration(5)
    .padding(30)
    .show();
    Index

    Constructors

    Methods

    • Close the alert immediately

      Returns void

    • Set how long the alert is displayed

      Parameters

      • seconds: number

        Duration in seconds (default: 5.0)

      Returns HSUIAlert

      Self for chaining

    • Set the font for the alert text

      Parameters

      • font: HSFont

        An HSFont object (e.g., HSFont.headline())

      Returns HSUIAlert

      Self for chaining

    • Set the padding around the alert text

      Parameters

      • points: number

        Padding in points (default: 20)

      Returns HSUIAlert

      Self for chaining

    • Set a custom position for the alert When a position is set, the alert is shown at those coordinates and will not be stacked with other alerts. Coordinates are in points from the top-left of the visible screen area (below the menu bar), with y increasing downward.

      Parameters

      • dict: Record<string, any>

        Dictionary with x and y coordinates

      Returns HSUIAlert

      Self for chaining

    • Show the alert

      Returns HSUIAlert

      Self for chaining (can store reference to close manually)