Coder Social home page Coder Social logo

i3ipc-rs's Introduction

i3ipc-rs

Build Status Crate Docs

A Rust library for controlling i3-wm through its IPC interface.

Usage

Add this to your Cargo.toml

[dependencies.i3ipc]
version = "0.10.1"

Messages:

extern crate i3ipc;
use i3ipc::I3Connection;

fn main() {
    // establish a connection to i3 over a unix socket
    let mut connection = I3Connection::connect().unwrap();
    
    // request and print the i3 version
    println!("{}", connection.get_version().unwrap().human_readable);
    
    // fullscreen the focused window
    connection.run_command("fullscreen").unwrap();
}

Events:

extern crate i3ipc;
use i3ipc::I3EventListener;
use i3ipc::Subscription;
use i3ipc::event::Event;

fn main() {
    // establish connection.
    let mut listener = I3EventListener::connect().unwrap();

    // subscribe to a couple events.
    let subs = [Subscription::Mode, Subscription::Binding];
    listener.subscribe(&subs).unwrap();

    // handle them
    for event in listener.listen() {
        match event.unwrap() {
            Event::ModeEvent(e) => println!("new mode: {}", e.change),
            Event::BindingEvent(e) => println!("user input triggered command: {}", e.binding.command),
            _ => unreachable!()
        }
    }
}

Versioning

By default i3ipc-rs targets minimum i3 version 4.11. To unlock additional features you can increase this by selecting one of "i3-4-12", ..., "i3-4-14" in Cargo.toml.

[dependencies.i3ipc]
version = "0.10.1"
features = ["i3-4-14"]

Additions to the i3 IPC interface that are not understood by your compiled binary will generally return an Unknown value and log a warning to the target "i3ipc" using the log crate. Binaries using this library should install a logger to view details of such additions.

i3ipc-rs's People

Contributors

celti avatar chrde avatar emersion avatar jplatte avatar lbonn avatar lincheney avatar mosbasik avatar rkanati avatar soenkehahn avatar soumya92 avatar svenstaro avatar tmerr avatar wawe avatar

Watchers

 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.