From d15a39c817b45c4d807ab8be4a06c3977338b8e2 Mon Sep 17 00:00:00 2001 From: goatnath Date: Mon, 14 Sep 2026 01:46:02 +0530 Subject: [PATCH] msg: handle EventStream specially in raw-request When a raw-request is for an EventStream, continuously read events from the socket and print them as JSON lines, matching the behavior of the event-stream subcommand. --- src/ipc/client.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ipc/client.rs b/src/ipc/client.rs index cf6fb64c..58c2e09c 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -61,6 +61,8 @@ pub fn handle_msg(mut msg: Msg, json: bool, print_request: bool) -> anyhow::Resu println!("{json_str}"); return Ok(()); } + + let is_event_stream = matches!(request, Request::EventStream); let mut socket = Socket::connect().context("error connecting to the niri socket")?; let result = socket.send(request); @@ -563,6 +565,15 @@ pub fn handle_msg(mut msg: Msg, json: bool, print_request: bool) -> anyhow::Resu Msg::RawRequest => { let output = serde_json::to_string(&response).context("error formatting response")?; println!("{output}"); + + if is_event_stream { + let mut read_event = socket.read_events(); + loop { + let event = read_event().context("error reading event from niri")?; + let event = serde_json::to_string(&event).context("error formatting event")?; + println!("{event}"); + } + } } }