Alert.alert β€” Function

alert(message="Done!")

Display a cross-platform notification.

On MacOS, displays a notification window. On linux, tries to use notify-send, zenity, kdialog or xmessage, in that order. On Windows or WSL2, uses a toast notification.

Other platforms are not yet supported.

You can customize this function using set_alert_backend!.

Alert.alert_REPL! β€” Method

alert_REPL!(;[duration=2.0], [message="Done!"])

Wraps all code passed to the REPL in an @alert macro with the given arguments. Hence, if anything you run in the REPL takes longer than duration seconds, an alert notification will be displayed. You can set the duration to Inf to turn off the notification.

NOTE: onerror must always be false; therefore no alert will be shown when a

command errors. This is a limitation of REPL design. All REPL statements are expected to be top-level statements and inserting a try/catch block automatically would prevent the assignment of global variables at the REPL.

Alert.apple_alert! β€” Method
apple_alert!(;title="Julia", subtitle="", sound="")

Use a nicer appearing backend for MacOS systems.

Arguments

  • title::AbstractString="Julia": Notification title
  • subtitle::AbstractString="": Notification subtitle
  • sound::AbstractString="": Notification sound
  • clear::Bool: if true, clears all apple_alert settings and reverts to default backend

Examples

julia> Alert.apple_alert!(title="π’₯π“Šπ“π’Ύπ’Ά", subtitle="Alert.jl", sound="Crystal");

julia> alert("From a fancy backend!")
Alert.apple_backend β€” Method
apple_backend(title="Julia", subtitle="", sound="", test=false)

Helper function to define a Script Editor backend for MacOS systems.

Arguments

  • title::AbstractString="Julia": Notification title
  • subtitle::AbstractString="": Notification subtitle
  • sound::AbstractString="": Notification sound
  • test::Bool=false: Display a sample notification when initializing

Examples

julia> mybackend = Alert.apple_backend(title="π’₯π“Šπ“π’Ύπ’Ά", subtitle="Alert.jl", sound="Crystal");

julia> Alert.set_alert_backend!(mybackend);

julia> alert("From a fancy backend!")
Alert.set_alert_backend! β€” Method

setalertbackend!(fn)

Defines a custom backend for how alert sends messages to the user. The argument should be a function of one argument (a string) which displays the message to the user via some native UX api call.

If you wish to revert to the default backend, call this method with no arguments.

Alert.@alert β€” Macro
@alert [duration=2.0] [message="Done!"] [onerror=true] [body...]

Calls alert if body takes longer than duration (default to 2.0) seconds to complete; Posts the alert even if body throws an exception so long as onerror=true.

Settings (e.g. duration) are specified as keyword arguments.

NOTE: when onerror=true the body is run in a try/catch block, meaning

any variables you define inside @alert are local.