https://github.com/leshow/tokio-i3ipc
i3 IPC in tokio + sync + standalone types crate
https://github.com/leshow/tokio-i3ipc
Last synced: about 1 year ago
JSON representation
i3 IPC in tokio + sync + standalone types crate
- Host: GitHub
- URL: https://github.com/leshow/tokio-i3ipc
- Owner: leshow
- License: mit
- Created: 2019-03-09T07:15:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-15T08:47:35.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T03:52:05.889Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 296 KB
- Stars: 36
- Watchers: 1
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# i3ipc
## tokio-i3ipc
**Now with tokio 1.0 support!** Use version 0.12.0 and up for tokio 1.0
[](https://github.com/leshow/tokio-i3ipc/actions)
[](https://crates.io/crates/tokio-i3ipc)
[](https://docs.rs/tokio-i3ipc)
This crate provides types and functions for working with i3's IPC protocol (and some basic sway support) within tokio. It re-exports the subcrate `i3ipc-types` because it is also used for a synchronous version of the code.
see [here](https://github.com/leshow/tokio-i3ipc/tree/master/tokio-i3ipc) for tokio runtime specific i3
## async-i3ipc
[](https://crates.io/crates/async-i3ipc)
[](https://docs.rs/async-i3ipc)
see [here](https://github.com/leshow/tokio-i3ipc/tree/master/async-i3ipc) for async-std specific i3 ipc (and sway-- not all fields supported)
## std synchronous IO i3ipc
[](https://crates.io/crates/i3_ipc)
[](https://docs.rs/i3_ipc)
see [here](https://github.com/leshow/tokio-i3ipc/tree/master/i3-ipc) for synchronous specific i3 ipc (and sway-- not all fields supported)
### Using tokio-i3ipc
I expect the most common use case will be to subscribe to some events and listen:
```rust
use std::io;
use tokio::stream::StreamExt;
use tokio_i3ipc::{
event::{Event, Subscribe},
I3,
};
#[tokio::main(flavor = "current_thread")]
async fn main() -> io::Result<()> {
let mut i3 = I3::connect().await?;
let resp = i3.subscribe([Subscribe::Window]).await?;
println!("{:#?}", resp);
let mut listener = i3.listen();
while let Some(event) = listener.next().await {
match event? {
Event::Workspace(ev) => println!("workspace change event {:?}", ev),
Event::Window(ev) => println!("window event {:?}", ev),
Event::Output(ev) => println!("output event {:?}", ev),
Event::Mode(ev) => println!("mode event {:?}", ev),
Event::BarConfig(ev) => println!("bar config update {:?}", ev),
Event::Binding(ev) => println!("binding event {:?}", ev),
Event::Shutdown(ev) => println!("shutdown event {:?}", ev),
Event::Tick(ev) => println!("tick event {:?}", ev),
}
}
Ok(())
}
```
### Contributing
Contributions PRs, issues, comments, are all welcome!