#desktop #notification #notify #dbus #libnotify

notify-rust

Show desktop notifications. Pure Rust dbus client and server.

27 releases (stable)

3.5.0 Oct 21, 2018
3.4.2 Aug 19, 2017
3.4.1 Jul 9, 2017
3.3.0 Mar 29, 2017
0.9.0 Jun 30, 2015

#2 in Unix APIs

Download history 408/week @ 2018-12-20 229/week @ 2018-12-27 341/week @ 2019-01-03 222/week @ 2019-01-10 295/week @ 2019-01-17 225/week @ 2019-01-24 400/week @ 2019-01-31 531/week @ 2019-02-07 484/week @ 2019-02-14 190/week @ 2019-02-21 177/week @ 2019-02-28 124/week @ 2019-03-07 139/week @ 2019-03-14 440/week @ 2019-03-21 58/week @ 2019-03-28

1,610 downloads per month
Used in 23 crates (21 directly)

MIT/Apache

68KB
1K SLoC

notify-rust

Travis license Crates.io version documentation

Shows desktop notifications. This implementation does not rely on libnotify, as it is using dbus-rs. Basic notification features are supported, more sophisticated functionality will follow. The API shown below should be stable.

#Cargo.toml
[dependencies]
notify-rust = "3"

Requirements

  • rustc >= 1.18.0
  • linux, with libdbus-1
  • macos
  • no windows support

Compiletime requirements

  • libdbus-1-dev

Examples

Example 1 (Simple Notification)

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

Example 2 (Persistent Notification)

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

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.

Platform support

This library shines on linux and bsd, which is it's original target platform. Lately it gained support for macOS, 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.

Dependencies

~1.5MB
~17K SLoC