wayle_hyprland/lib.rs
1//! Reactive bindings to Hyprland compositor state via IPC.
2//!
3//! # Overview
4//!
5//! Connects to Hyprland's Unix domain sockets to query state and receive events.
6//! State is exposed through reactive [`Property`] fields that update automatically
7//! when Hyprland emits relevant events.
8//!
9//! # Reactive Properties
10//!
11//! All state fields use [`Property<T>`] which supports two access patterns:
12//!
13//! - **Snapshot**: `property.get()` returns the current value
14//! - **Stream**: `property.watch()` returns a stream that yields on changes
15//!
16//! ```no_run
17//! # use wayle_hyprland::HyprlandService;
18//! # use futures::StreamExt;
19//! # async fn example() -> wayle_hyprland::Result<()> {
20//! let service = HyprlandService::new().await?;
21//!
22//! // Get current workspaces
23//! let workspaces = service.workspaces.get();
24//!
25//! // Watch for workspace changes
26//! let mut stream = service.workspaces.watch();
27//! while let Some(workspaces) = stream.next().await {
28//! println!("Workspaces changed: {:?}", workspaces.len());
29//! }
30//! # Ok(())
31//! # }
32//! ```
33//!
34//! # Service Fields
35//!
36//! The [`HyprlandService`] exposes:
37//!
38//! - `workspaces` - All workspaces (normal and special)
39//! - `clients` - All open windows
40//! - `monitors` - Connected displays
41//! - `layers` - Layer shell surfaces (panels, overlays, etc.)
42//!
43//! # Event Streaming
44//!
45//! Raw Hyprland events can be streamed via [`HyprlandService::events()`]:
46//!
47//! ```no_run
48//! # use wayle_hyprland::HyprlandService;
49//! # use futures::StreamExt;
50//! # async fn example() -> wayle_hyprland::Result<()> {
51//! let service = HyprlandService::new().await?;
52//! let mut events = service.events();
53//!
54//! while let Some(event) = events.next().await {
55//! println!("Event: {:?}", event);
56//! }
57//! # Ok(())
58//! # }
59//! ```
60//!
61//! # IPC Commands
62//!
63//! Execute Hyprland commands via [`HyprlandService::dispatch()`]:
64//!
65//! ```no_run
66//! # use wayle_hyprland::HyprlandService;
67//! # async fn example() -> wayle_hyprland::Result<()> {
68//! let service = HyprlandService::new().await?;
69//! service.dispatch("workspace 1").await?;
70//! # Ok(())
71//! # }
72//! ```
73//!
74//! [`Property`]: wayle_core::Property
75//! [`Property<T>`]: wayle_core::Property
76
77mod core;
78mod discovery;
79mod error;
80mod ipc;
81mod monitoring;
82mod service;
83mod types;
84
85pub use core::{client::Client, monitor::Monitor, workspace::Workspace};
86
87pub use error::{Error, Result};
88pub use ipc::events::types::HyprlandEvent;
89pub use service::HyprlandService;
90pub(crate) use types::*;
91pub use types::{
92 Address, BindData, CursorPosition, DeviceInfo, FocusHistoryId, MonitorId, ProcessId,
93 ScreencastOwner, WorkspaceId, WorkspaceInfo, WorkspaceRule,
94};
95
96#[doc = include_str!("../README.md")]
97#[cfg(doctest)]
98pub struct ReadmeDocTests;