#interface #window #version #sockets

i3ipc

A library for controlling i3-wm through its IPC interface

17 releases (9 breaking)

Uses old Rust 2015

0.10.1 Mar 12, 2019
0.9.0 Nov 10, 2018
0.8.2 Oct 7, 2017
0.4.2 Sep 16, 2016
0.3.0 Jul 18, 2015

#582 in Hardware support

Download history 441/week @ 2024-12-10 204/week @ 2024-12-17 69/week @ 2024-12-24 125/week @ 2024-12-31 175/week @ 2025-01-07 331/week @ 2025-01-14 245/week @ 2025-01-21 144/week @ 2025-01-28 481/week @ 2025-02-04 277/week @ 2025-02-11 171/week @ 2025-02-18 249/week @ 2025-02-25 104/week @ 2025-03-04 324/week @ 2025-03-11 276/week @ 2025-03-18 197/week @ 2025-03-25

922 downloads per month
Used in fewer than 23 crates

MIT license

63KB
1K SLoC

i3ipc-rs

Build Status 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.

Dependencies

~0.6–1.2MB
~23K SLoC