Skip to content

Commit 218367b

Browse files
committed
add some docs
1 parent 5aef814 commit 218367b

File tree

1 file changed

+8
-0
lines changed
  • cidre/examples/ns-workspace-notifications

1 file changed

+8
-0
lines changed

cidre/examples/ns-workspace-notifications/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
/// # Workspace Notifications Example
2+
///
3+
/// This example demonstrates how to observe macOS workspace notifications using the cidre library.
4+
/// It registers observers for various application events (hiding, launching, activating, and deactivating)
5+
/// and prints information about these events when they occur.
6+
///
17
use cidre::{blocks, ns, objc::Obj};
28

39
fn main() {
410
let block = |n: &ns::Notification| {
511
println!("{:?}", n.name());
612
let user_info = n.user_info().unwrap();
13+
714
if let Some(app) = user_info.get(ns::workspace::notification::app_key()) {
815
if let Some(app) = app.try_cast(ns::RunningApp::cls()) {
916
println!("{app:?}");
1017
}
1118
}
1219
};
1320

21+
// One block for all notifications
1422
let mut block = blocks::SyncBlock::new1(block);
1523

1624
let notifications = [

0 commit comments

Comments
 (0)