ksway

docs.rs

This library provides a convenient interface for quickly making scripts for i3 and sway (since they share an IPC interface API). It will mainly be focused on sway if that compatibility changes.

It will also be a container for the many scripts I use on a daily basis which live under examples/.

Those examples are the best resource for learning how to use this for complex situations, but here are some small examples:

Short examples

connect

rust let mut client = Client::connect()?; let mut client = Client::connect_to_path("/run/user/1000/sway-ipc.1000.1.sock")?;

run commands

The criteria implementation is complete and up to date as of 2019-07-27.

```rust use ksway::{ipc_command, command};

// These are equivalent client.ipc(ipccommand::run("exec st"))?; client.ipc(ipccommand::run(command::raw("exec st"))?; client.ipc(ipc_command::run(command::exec("st"))?; client.run(command::exec("st"))?;

// The benefit of using command is the additional methods such as .with_criteria

use ksway::criteria::*;

let cmd = command::raw("focus").with_criteria(vec![floating(), title("mpv")]); client.run(cmd)?;

// criteria examples let cmd = command::raw("focus").withcriteria(vec![workspace(focused())]); let cmd = command::raw("focus").withcriteria(vec![conid(123)]) let cmd = command::raw("focus").withcriteria(vec![con_id(focused())]) ```

get_*

```rust use ksway::ipc_command;

client.ipc(ipccommand::gettree())?;

let treedata = json::parse(str::fromutf8(&client.ipc(ipccommand::gettree())?)?)?;

client.ipc(ipccommand::getworkspaces())?; client.ipc(ipccommand::getversion())?; ```

subscribe*

```rust use ksway::IpcEvent;

let rx = client.subscribe(vec![IpcEvent::Window, IpcEvent::Tick])?; loop { while let Ok((payloadtype, payload)) = rx.tryrecv() { match payload_type { IpcEvent::Window => {}, _ => {}, } } client.poll()?; } ```

Full examples

TODO

Open Design Questions