From 131051a69f51a4f41bd65fc1984d3fefcd39150e Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 16 Jan 2021 22:35:08 +0100 Subject: [PATCH] Make the window event subscription and JSON parsing work --- src/bin/swayrd.rs | 18 ++++++------------ src/ipc.rs | 7 ------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/bin/swayrd.rs b/src/bin/swayrd.rs index e1549fb..bc5bb0a 100644 --- a/src/bin/swayrd.rs +++ b/src/bin/swayrd.rs @@ -14,21 +14,12 @@ fn main() { Arc::new(RwLock::new(HashMap::new())); let subscriber_handle = thread::spawn(|| { - let x = proc::Command::new("swaymsg") - .arg("-t") - .arg("subscribe") - .arg("[window]") - .output() - .expect("Failed to subscribe to window events"); - println!( - "{}", - String::from_utf8(x.stdout).expect("Wrong string data!") - ); let child = proc::Command::new("swaymsg") .arg("--monitor") + .arg("--raw") .arg("-t") .arg("subscribe") - .arg("'[window]'") + .arg("[\"window\"]") .stdout(proc::Stdio::piped()) .spawn() .expect("Failed to subscribe to window events"); @@ -37,7 +28,10 @@ fn main() { let stream = Deserializer::from_reader(stdout).into_iter::(); for res in stream { match res { - Ok(msg) => println!("Got msg: {:?}", msg), + Ok(win_ev) => println!( + "WindowEvent {:?} for node {:?}", + win_ev.change, win_ev.container.id + ), Err(err) => panic!("{:?}", err), } } diff --git a/src/ipc.rs b/src/ipc.rs index fe72752..567f3a6 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -208,13 +208,6 @@ pub enum WindowEventType { Mark, } -#[derive(Deserialize, Debug)] -#[allow(dead_code)] -pub struct Reply { - pub success: bool, - pub error: String, -} - #[derive(Deserialize, Debug)] #[allow(dead_code)] pub struct WindowEvent {