plushie/effects

Platform effects: file dialogs, clipboard, notifications.

Each function returns a Command(msg) that the runtime sends to the bridge as an effect request. Results arrive as EffectResponse events with a correlated request_id.

Types

Options for file dialog effects.

pub type FileDialogOpt {
  DialogTitle(String)
  DefaultPath(String)
  Filters(List(#(String, String)))
}

Constructors

  • DialogTitle(String)

    Title shown in the dialog window.

  • DefaultPath(String)

    Default starting path.

  • Filters(List(#(String, String)))

    File type filters as (label, pattern) pairs. Example: #(“Images”, “.png;.jpg”)

Urgency level for notifications.

pub type NotifUrgency {
  Low
  Normal
  Critical
}

Constructors

  • Low
  • Normal
  • Critical

Options for notification effects.

pub type NotificationOpt {
  NotifIcon(String)
  NotifTimeout(Int)
  Urgency(NotifUrgency)
  Sound(String)
}

Constructors

  • NotifIcon(String)

    Path to notification icon.

  • NotifTimeout(Int)

    Auto-dismiss timeout in milliseconds.

  • Urgency(NotifUrgency)

    Notification urgency level.

  • Sound(String)

    Sound theme name to play (e.g. “message-new-instant”).

Values

pub fn clipboard_clear() -> command.Command(msg)

Clear the system clipboard.

pub fn clipboard_read() -> command.Command(msg)

Read text from the system clipboard.

pub fn clipboard_read_html() -> command.Command(msg)

Read HTML from the system clipboard.

pub fn clipboard_read_primary() -> command.Command(msg)

Read text from the primary selection (X11).

pub fn clipboard_write(text: String) -> command.Command(msg)

Write text to the system clipboard.

pub fn clipboard_write_html(
  html: String,
  alt: option.Option(String),
) -> command.Command(msg)

Write HTML to the system clipboard, with optional plain-text fallback.

pub fn clipboard_write_primary(
  text: String,
) -> command.Command(msg)

Write text to the primary selection (X11).

pub fn default_timeout(kind: String) -> Int

Returns the default timeout in milliseconds for the given effect kind. File dialogs get 120s (user interaction), clipboard and notification ops get 5s. Unknown kinds fall back to 30s.

pub fn directory_select(
  opts: List(FileDialogOpt),
) -> command.Command(msg)

Open a directory selection dialog.

pub fn directory_select_multiple(
  opts: List(FileDialogOpt),
) -> command.Command(msg)

Open a multiple directory selection dialog.

pub fn file_open(
  opts: List(FileDialogOpt),
) -> command.Command(msg)

Open a single file selection dialog.

pub fn file_open_multiple(
  opts: List(FileDialogOpt),
) -> command.Command(msg)

Open a multiple file selection dialog.

pub fn file_save(
  opts: List(FileDialogOpt),
) -> command.Command(msg)

Open a file save dialog.

pub fn notification(
  title: String,
  body: String,
  opts: List(NotificationOpt),
) -> command.Command(msg)

Show a desktop notification.

Search Document