Expand description
§sawfish-client
A library for handling communication with the Sawfish window manager to
allow remote form evaluation. In other words, Rust implementation of the
sawfish-client program shipped with Sawfish.
§Example usage
fn sawfish_eval(form: &str) -> Result<Vec<u8>, ()> {
// Establish connection. open will read
// $DISPLAY to get the display name.
let mut conn = sawfish_client::open(None)
.map_err(|err| { eprintln!("{err}"); })?;
// Evaluate the form.
println!(">>> {form}");
match conn.eval(form) {
Err(err) => {
eprintln!("{err}");
Err(())
}
Ok(Err(data)) => {
let msg = String::from_utf8_lossy(&data);
println!("!!! {msg}");
Err(())
}
Ok(Ok(data)) => {
let msg = String::from_utf8_lossy(&data);
println!("<<< {msg}");
Ok(data)
}
}
}Furthermore, the crate comes with an example binary which can be examined to see how the library functions.
§Features
The crate defines the following Cargo feature:
-
async— addsAsyncClienttype which usesfuture_iotraits to support asynchronous I/O. It can be used with any async runtime so long as a compatible async I/O object is provided. Because opening the Unix socket depends on the runtime, withAsyncClientthat now must be done by the caller. -
tokio— addsTokioClienttype alias andopen_tokiofunction which simplify using the library with the Tokio async runtime. This feature does not introduce any new capabilities tosawfish-clientbut is provided for convenience of Tokio users. This feature impliesasync. -
expemirental-xcb— adds experimental support for X11-based communication with Sawfish. Normally, the library connects to Sawfish via a Unix socket. With this feature, if connecting to the socket fails, it tries to use X11-based communication instead. Note that this feature is only supported with synchronous client.
Structs§
- Async
Client async - A connection to the Sawfish window manager using asynchronous I/O.
- Client
- A connection to the Sawfish window manager.
Enums§
- Conn
Error - Error during establishing connection to the Sawfish server.
- Eval
Error - Error during sending form for evaluation.
Functions§
- open
- Opens a connection to the Sawfish server.
- open_
tokio tokio - Opens a connection to the Sawfish server using the Tokio runtime.
- server_
path async - Returns path of the Unix socket the Sawfish server is (or should be) listening on.
Type Aliases§
- Eval
Response - Result of a form evaluation.
- Tokio
Client tokio - An alias for the
AsyncClientwhich uses Tokio runtime Unix stream.