Giter VIP home page Giter VIP logo

tokio-i3ipc's Introduction

i3ipc

tokio-i3ipc

Now with tokio 1.0 support! Use version 0.12.0 and up for tokio 1.0

Build Status Crate API

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 for tokio runtime specific i3

async-i3ipc

Crate API

see here for async-std specific i3 ipc (and sway-- not all fields supported)

std synchronous IO i3ipc

Crate API

see here 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:

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!

tokio-i3ipc's People

Contributors

leshow avatar sean1708 avatar f-koehler avatar purplemyst avatar pcpthm avatar chmln avatar lawngnome avatar andreasolofsson avatar ohazi avatar expandingman avatar johndowson avatar janwojcicki avatar nicklan avatar tombl avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.