#desktop #notification #notify #linux #macos

notify-rust

Show desktop notifications (linux, bsd, mac). Pure Rust dbus client and server.

34 releases (stable)

✓ Uses Rust 2018 edition

new 4.0.0-alpha.3 Dec 7, 2019
4.0.0-alpha.2 Nov 20, 2019
3.6.3 Nov 2, 2019
3.6.0 May 16, 2019
0.9.0 Jun 30, 2015

#5 in Unix APIs

Download history 690/week @ 2019-08-24 183/week @ 2019-08-31 455/week @ 2019-09-07 542/week @ 2019-09-14 352/week @ 2019-09-21 414/week @ 2019-09-28 285/week @ 2019-10-05 241/week @ 2019-10-12 313/week @ 2019-10-19 196/week @ 2019-10-26 443/week @ 2019-11-02 536/week @ 2019-11-09 1470/week @ 2019-11-16 584/week @ 2019-11-23 1279/week @ 2019-11-30

2,370 downloads per month
Used in 30 crates (28 directly)

MIT/Apache

73KB
1K SLoC

notify-rust

Travis license Crates.io version documentation maintenance contributors

A not so well-named library for displaying desktop notifications. On linux/bsd it uses dbus-rs, so it does not rely on libnotify. On macos it uses mac-notification-sys.

[dependencies]
notify-rust = "3"

Requirements

  • rustc >= 1.36
  • linux, with libdbus (see dbus-rs)
  • macos
  • no windows support, yet

Examples

Example 1 (Simple Notification)

use notify_rust::Notification;
Notification::new()
    .summary("Firefox News")
    .body("This will almost look like a real firefox notification.")
    .icon("firefox")
    .show()?;

Example 2 (Persistent Notification)

use notify_rust::Notification;
use notify_rust::Hint;
Notification::new()
    .summary("Category:email")
    .body("This has nothing to do with emails.\nIt should not go away until you acknowledge 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()?;

Usage & Documentation

Please see the documentation for current examples.

Commandline tool

Checkout toastify, it exposes most of the functionality of the lib to the commandline.

macOS support

This library shines on linux and bsd, which is its original target platform. Lately it gained support for macOS thanks to mac-notification-sys. However this only includes a small subset of the current functionality, since NSNotifications don't have as many features. Please refer to the You are a versed macOS UI developer with mad Objective-C skillz? PRSV.

Contribution

Any help in form of descriptive and friendly issues or comprehensive pull requests are welcome!

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in notify-rust by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–0.8MB
~16K SLoC