#notifications #reuse #created #desktop-notifications #notify-rust #reuse-notification

reuse-notifications

Allows to reuse desktop notifications created by notify-rust

2 releases

Uses old Rust 2015

0.1.1 Apr 29, 2018
0.1.0 Apr 29, 2018

#27 in #desktop-notifications

22 downloads per month

MIT license

7KB
77 lines

Allows to reuse notifications created by notify-rust , replacing the contents of an already existing notification, instead of creating a new one.

Examples

Example for a single notification

use notify_rust::*;
use reuse_notification::ReuseNotification;

Notification::new()
    .summary("Firefox News")
    .body("This will almost look like a real firefox notification.")
    .icon("firefox")
    .timeout(Timeout::Milliseconds(6000))
    .reuse() // <-- instead of `show()`
    .unwrap();

Example for different reusable notifications

In order to overwrite a specific notification, provide a string to .reuse().

Future calls to .reuse() with the same string will replace the contents of the old notification with the new ones in the new notification instance.

use notify_rust::*;
use reuse_notification::ReuseNotification;

Notification::new()
    .summary("Firefox News")
    .body("This will almost look like a real firefox notification.")
    .icon("firefox")
    .timeout(Timeout::Milliseconds(6000))
    .reuse("firefox_notification") // <-- instead of `show()`
    .unwrap();

Notification::new()
    .summary("Other News")
    .body("This will almost look like a real firefox notification.")
    .icon("firefox")
    .timeout(Timeout::Milliseconds(6000))
    .reuse("other_notification") // <-- instead of `show()`
    .unwrap();

Notification::new()
    .summary("Firefox News 2")
    .body("This will reuse the previous 'firefox notification'.")
    .icon("firefox")
    .timeout(Timeout::Milliseconds(6000))
    .reuse("firefox_notification") // <-- instead of `show()`
    .unwrap();

Dependencies

~0.4–1.8MB
~31K SLoC