Skip to content
/ i3ipc-rs Public
forked from tmerr/i3ipc-rs

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

License

Notifications You must be signed in to change notification settings

wawe/i3ipc-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i3ipc-rs

Build Status

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

Documentation

##Usage Add this to your Cargo.toml

[dependencies]
i3ipc = "0.4.2"

##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.command("fullscreen").unwrap();
}
```

## Events:

```rust
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!()
        }
    }
}
```

## Status
This library was last updated for **i3 version 4.11**. It is generally forward compatible, but not backward compatible. Contributions are welcome!

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.6%
  • Shell 0.4%