| 1 | <div align="center"> |
| 2 | |
| 3 | # notify-rust |
| 4 | |
| 5 | [](https://github.com/hoodie/notify-rust/actions?query=workflow%3A"Continuous+Integration") |
| 6 | [](https://crates.io/crates/notify-rust) |
| 7 | [](https://github.com/hoodie/notify-rust/graphs/contributors) |
| 8 |  |
| 9 | |
| 10 | [](https://crates.io/crates/notify-rust/) |
| 11 | [](https://docs.rs/notify-rust/) |
| 12 | [](https://crates.io/crates/notify-rust/) |
| 13 | |
| 14 | </div> |
| 15 | |
| 16 | A not so well-named library for displaying desktop notifications. |
| 17 | |
| 18 | ```toml |
| 19 | [dependencies] |
| 20 | notify-rust = "4" |
| 21 | ``` |
| 22 | |
| 23 | ## Usage & Documentation |
| 24 | |
| 25 | Please see the [documentation](https://docs.rs/crate/notify-rust/) for current examples. |
| 26 | |
| 27 | ### Simple Notification |
| 28 | |
| 29 | ```rust |
| 30 | use notify_rust::Notification; |
| 31 | Notification::new() |
| 32 | .summary("Firefox News") |
| 33 | .body("This will almost look like a real firefox notification.") |
| 34 | .icon("firefox") |
| 35 | .show()?; |
| 36 | ``` |
| 37 | |
| 38 | ### Persistent Notification |
| 39 | |
| 40 | ```rust |
| 41 | use notify_rust::{Notification, Hint}; |
| 42 | Notification::new() |
| 43 | .summary("Category:email") |
| 44 | .body("This has nothing to do with emails.\nIt should not go away until you acknowledge it.") |
| 45 | .icon("thunderbird") |
| 46 | .appname("thunderbird") |
| 47 | .hint(Hint::Category("email".to_owned())) |
| 48 | .hint(Hint::Resident(true)) // this is not supported by all implementations |
| 49 | .timeout(0) // this however is |
| 50 | .show()?; |
| 51 | ``` |
| 52 | |
| 53 | ## Linux/BSD support |
| 54 | |
| 55 | The main audience of this library are Linux/BSD based desktop environments that follow the XDG specification (see [gnome dev docs](http://web.archive.org/web/20200606201408/https://developer.gnome.org/notification-spec/) or [libnotify docs](https://www.galago-project.org/specs/notification/0.9/index.html)). These include KDE, Gnome, XFCE, LXDC, Mate (and probably also most others that I haven't personally tested). |
| 56 | |
| 57 | ### Features |
| 58 | |
| 59 | #### `images` |
| 60 | |
| 61 | Enables sending of images with notifications via the `image_data()` / pixel-buffer API. This is only supported on XDG and requires the [**image** crate](https://lib.rs/image) as well as [**lazy_static**](https://lib.rs/lazy_static) to determine the supported spec-version on startup. |
| 62 | |
| 63 | > **Note on `image_path()`:** Passing an image by file path via `image_path()` does **not** require the `images` feature on any platform. On Linux/BSD it maps to the `image-path` XDG hint, on macOS it maps to `content_image` in `mac-notification-sys`, and on Windows it is passed directly to `winrt-notification` — all without any additional dependencies. |
| 64 | |
| 65 | #### `d` |
| 66 | |
| 67 | Enables the usage of [**dbus-rs**](https://lib.rs/dbus) instead of [**zbus**](https://lib.rs/zbus) (also XDG only). |
| 68 | This is functionally identical to the default feature set. |
| 69 | **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`**. |
| 70 | |
| 71 | ## macOS support |
| 72 | |
| 73 | This library shines on linux and bsd, which is its original target platform. |
| 74 | Lately it gained support for macOS thanks to [mac-notification-sys](https://crates.io/crates/mac-notification-sys). |
| 75 | However this only includes a small subset of the current functionality, since [`NSNotification`](https://developer.apple.com/reference/foundation/nsnotification)s don't have as many features. |
| 76 | |
| 77 | **call for participation:** You are a versed macOS UI developer with mad Objective-C skillz? <abbr title="pull request sil vous plait">PRSV</abbr>. |
| 78 | |
| 79 | ## Windows support |
| 80 | |
| 81 | Similar to macOS we support windows via the help of [winrt-notification](https://crates.io/crates/winrt-notification). |
| 82 | |
| 83 | ## Commandline tool |
| 84 | |
| 85 | Checkout [toastify](https://github.com/hoodie/toastify), it exposes most of the functionality of the lib to the commandline. |
| 86 | |
| 87 | ## Contributing |
| 88 | |
| 89 | Any help in form of descriptive and friendly [issues](https://github.com/hoodie/notify-rust/issues) or comprehensive pull requests are welcome! |
| 90 | |
| 91 | 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. |
| 92 | |
| 93 | ### Conventions |
| 94 | |
| 95 | 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](https://crates.io/crates/convco). |
| 96 | |
| 97 | ### Recognition |
| 98 | |
| 99 | Thanks goes to these wonderful people: |
| 100 | |
| 101 | <a href="https://github.com/hoodie/notify-rust/graphs/contributors"> |
| 102 | <img src="https://contrib.rocks/image?repo=hoodie/notify-rust" /> |
| 103 | </a> |
| 104 | |
| 105 | ### License |
| 106 | |
| 107 | <sup> |
| 108 | `notify-rust` is licensed under either of <a href="LICENSE-APACHE">Apache License, Version |
| 109 | 2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option. |
| 110 | </sup> |
| 111 | |
| 112 | <br> |
| 113 | |
| 114 | <sub> |
| 115 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 116 | for inclusion in this crate by you, as defined in the Apache-2.0 license, shall |
| 117 | be dual licensed as above, without any additional terms or conditions. |
| 118 | </sub> |