mirror of
https://gitlab.com/hyask/swaysome.git
synced 2025-12-10 07:44:43 +01:00
lib: add get_tree, useful for testing
This commit is contained in:
parent
ab32878de5
commit
ffc73fd832
1 changed files with 12 additions and 0 deletions
12
src/lib.rs
12
src/lib.rs
|
|
@ -21,6 +21,7 @@ const RUN_COMMAND: u32 = 0;
|
|||
const GET_WORKSPACES: u32 = 1;
|
||||
// const SUBSCRIBE: u32 = 2;
|
||||
const GET_OUTPUTS: u32 = 3;
|
||||
const GET_TREE: u32 = 4;
|
||||
|
||||
pub struct SwaySome {
|
||||
socket: Cell<Option<UnixStream>>,
|
||||
|
|
@ -171,6 +172,17 @@ impl SwaySome {
|
|||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Only used in tests
|
||||
*/
|
||||
pub fn get_tree(&self) -> serde_json::Value {
|
||||
self.send_msg(GET_TREE, "");
|
||||
match self.read_msg() {
|
||||
Ok(msg) => serde_json::from_str(&msg).expect("Failed to parse JSON for get_tree"),
|
||||
Err(_) => panic!("Unable to get current workspace"),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_outputs(&self) -> Vec<Output> {
|
||||
self.send_msg(GET_OUTPUTS, "");
|
||||
let o = match self.read_msg() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue