5 releases
0.1.4 | May 7, 2023 |
---|---|
0.1.3 | Feb 16, 2023 |
0.1.2 | Dec 1, 2022 |
0.1.1 | Nov 29, 2022 |
0.1.0 | Nov 28, 2022 |
#849 in Unix APIs
9KB
180 lines
Iterator over focused window change on Linux
Example usage:
The following will print the window that gets focused every time the active window changes.
window
can be None
if there is no active window.
use focus_monitor::FocusMonitor;
fn main() -> anyhow::Result<()> {
let focus_monitor = FocusMonitor::try_new()?;
for window in focus_monitor {
let window = window?;
println!("{:?}", window);
}
Ok(())
}
Async
To enable AsyncFocusMonitor
use features=["tokio"]
in Cargo.toml
:
focus_monitor = { version = "0.1", features = ["tokio"] }
And you can use it like this:
use focus_monitor::AsyncFocusMonitor;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut focus_monitor = AsyncFocusMonitor::try_new()?;
let window = focus_monitor.recv().await?;
println!("{:?}", window);
}
lib.rs
:
Iterator over focused window change on Linux
Example usage:
The following will print the window that gets focused every time the active window changes.
window
can be None
if there is no active window.
let focus_monitor = FocusMonitor::try_new()?;
for window in focus_monitor {
let window = window?;
println!("{:?}", window);
}
Dependencies
~0.9–6.5MB
~43K SLoC