Crate notify_rust [] [src]

Desktop Notifications for Rust.

Desktop notifications are popup messages generated to notify the user of certain events.

Examples

// Example 1 (Simple Notification)
use notify_rust::Notification;
use notify_rust::NotificationHint as Hint;

Notification::new()
    .summary("Firefox News")
    .body("This will almost look like a real firefox notification.")
    .icon("firefox")
    .timeout(6000) //milliseconds
    .show();

// Example 2 (Persistent Notification)
Notification::new()
    .summary("Category:email")
    .body("This has nothing to do with emails.\nIt should not go away untill you acknoledge it.")
    .icon("thunderbird")
    .appname("thunderbird")
    .hint(Hint::Category("email".to_owned()))
    .hint(Hint::Resident(true)) // this is not supported by all implementations
    .timeout(0) // this however is
    .show();

// Example 3 (Ask the user to do something)
Notification::new()
    .summary("click me")
    .action("default", "default")
    .action("clicked", "click here")
    .hint(Hint::Resident(true))
    .show_and_wait_for_action({|action|
        match action {
            "default" => {println!("so boring")},
            "clicked" => {println!("that was correct")},
            "__closed" => {println!("the notification was closed")}, // here "__closed" is a hardcoded keyword
            _ => ()
        }
    });

more examples in the repository.

Modules

server

Experimental server taking the place of your Desktop Environments Notification Server.

Structs

Notification

Desktop Notification.

ServerInformation

Return value of get_server_information().

Enums

NotificationHint
NotificationUrgency

Functions

close_notification

Close a Notification given by id.

get_capabilities

Get list of all capabilities of the running Notification Server.

get_server_information

Returns a struct containing ServerInformation.

wait_for_action_signal

Listens for the ActionInvoked(UInt32, String) Signal.