wayle_notification/lib.rs
1//! Desktop notification service implementing the freedesktop.org Desktop Notifications spec.
2//!
3//! # Overview
4//!
5//! Registers as `org.freedesktop.Notifications` on D-Bus to receive notifications from
6//! applications. Notifications are stored, displayed as popups, and can be dismissed
7//! or have actions invoked.
8//!
9//! # Reactive Properties
10//!
11//! Service state is exposed through [`Property`](wayle_core::Property) fields:
12//! - `.get()` returns a snapshot of the current value
13//! - `.watch()` returns a stream that yields on changes
14//!
15//! # Service Fields
16//!
17//! | Field | Type | Description |
18//! |-------|------|-------------|
19//! | `notifications` | `Vec<Arc<Notification>>` | All received notifications |
20//! | `popups` | `Vec<Arc<Notification>>` | Currently visible popups |
21//! | `popup_duration` | `u32` | Popup display time in ms |
22//! | `dnd` | `bool` | Do Not Disturb mode (suppresses popups) |
23//! | `remove_expired` | `bool` | Auto-remove expired notifications |
24//!
25//! # Example
26//!
27//! ```no_run
28//! use wayle_notification::NotificationService;
29//! use futures::StreamExt;
30//!
31//! # async fn example() -> Result<(), wayle_notification::Error> {
32//! let service = NotificationService::new().await?;
33//!
34//! // Snapshot access
35//! let count = service.notifications.get().len();
36//!
37//! // Reactive stream
38//! let mut stream = service.notifications.watch();
39//! while let Some(notifications) = stream.next().await {
40//! println!("{} notifications", notifications.len());
41//! }
42//! # Ok(())
43//! # }
44//! ```
45//!
46//! # Configuration
47//!
48//! | Method | Effect |
49//! |--------|--------|
50//! | `with_daemon()` | Control notifications from scripts or other processes |
51//!
52//! ```no_run
53//! use wayle_notification::NotificationService;
54//!
55//! # async fn example() -> Result<(), wayle_notification::Error> {
56//! let service = NotificationService::builder()
57//! .with_daemon()
58//! .build()
59//! .await?;
60//! # Ok(())
61//! # }
62//! ```
63//!
64//! # D-Bus Interface
65//!
66//! When `with_daemon()` is enabled, the service registers on the session bus.
67//!
68//! - **Service:** `com.wayle.Notifications1`
69//! - **Path:** `/com/wayle/Notifications`
70//! - **Interface:** `com.wayle.Notifications1`
71//!
72//! See [`dbus.md`](https://github.com/wayle-rs/wayle/blob/master/crates/wayle-notification/dbus.md) for the full interface specification.
73
74mod builder;
75/// Notification data structures and operations.
76pub mod core;
77pub(crate) mod daemon;
78/// Error types.
79pub mod error;
80pub(crate) mod events;
81mod glob;
82pub(crate) mod image_cache;
83pub(crate) mod monitoring;
84pub(crate) mod persistence;
85pub(crate) mod popup_timer;
86pub(crate) mod proxy;
87/// Service implementation.
88pub mod service;
89/// freedesktop notification types (Urgency, ClosedReason, Capabilities, etc.).
90pub mod types;
91pub(crate) mod wayle_daemon;
92mod wayle_proxy;
93
94pub use builder::NotificationServiceBuilder;
95pub use error::Error;
96pub use service::NotificationService;
97pub use wayle_proxy::WayleNotificationsProxy;
98
99#[doc = include_str!("../README.md")]
100#[cfg(doctest)]
101pub struct ReadmeDocTests;