Make the window event subscription and JSON parsing work

timeout_old
Tassilo Horn 4 years ago
parent 60eef662ba
commit 131051a69f
  1. 18
      src/bin/swayrd.rs
  2. 7
      src/ipc.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::<ipc::WindowEvent>();
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),
}
}

@ -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 {

Loading…
Cancel
Save