#desktop-notifications #notifications #desktop #client-server #dbus #notify

notify-rust

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

70 releases (stable)

4.11.3 Sep 10, 2024
4.11.0 Apr 4, 2024
4.10.0 Nov 16, 2023
4.8.0 Feb 19, 2023
0.9.0 Jun 30, 2015

#2 in GUI

Download history 30094/week @ 2024-08-04 30622/week @ 2024-08-11 25752/week @ 2024-08-18 28195/week @ 2024-08-25 33649/week @ 2024-09-01 26030/week @ 2024-09-08 24906/week @ 2024-09-15 24691/week @ 2024-09-22 29661/week @ 2024-09-29 28289/week @ 2024-10-06 32049/week @ 2024-10-13 29443/week @ 2024-10-20 32771/week @ 2024-10-27 33282/week @ 2024-11-03 28786/week @ 2024-11-10 32920/week @ 2024-11-17

131,502 downloads per month
Used in 204 crates (184 directly)

MIT/Apache

125KB
2.5K SLoC

notify-rust

build Crates.io contributors maintenance

version documentation license

A not so well-named library for displaying desktop notifications.

[dependencies]
notify-rust = "4"

Usage & Documentation

Please see the documentation for current examples.

Simple Notification

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

Persistent Notification

use notify_rust::{Notification, 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()?;

Linux/BSD support

The main audience of this library are Linux/BSD based desktop environments that follow the XDG specification (see gnome dev docs or libnotify docs). These include KDE, Gnome, XFCE, LXDC, Mate (and probably also most others that I haven't personally tested).

Features

images

Enables sending of images with notifications. This is only supported on XDG. This will add the image crate as a dependency as well as lazy_static to determine the supported spec spec-version on startup.

d

Enables the usage of dbus-rs instead of zbus (also XDG only). This is functionally identical to the default feature set. As long as you still compile with default-features this will only enable dbus-rs usage, but not default to it! In order to use the dbus-rs implementation set the environment variable DBUSRS or compile notify-rust with --no-default-features.

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.

call for participation: You are a versed macOS UI developer with mad Objective-C skillz? PRSV.

Windows support

Similar to macOS we support windows via the help of winrt-notification.

Commandline tool

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

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.

Conventions

The Changelog of this library is generated from its commit log, there any commit message must conform with https://www.conventionalcommits.org/en/v1.0.0/. For simplicity you could make your commits with convco.

Dependencies

~0–30MB
~457K SLoC