diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-05-11 10:14:01 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-05-11 21:51:26 -0700 |
| commit | 2aff1ec71a46487439d8785fd54c53dabe77023e (patch) | |
| tree | 80b8cd3b03538a4cebfde7d53120f47cfb00135b /src/ipc | |
| parent | 3466fc0a66a43bf2f959673ff303e9037488a173 (diff) | |
| download | niri-2aff1ec71a46487439d8785fd54c53dabe77023e.tar.gz niri-2aff1ec71a46487439d8785fd54c53dabe77023e.tar.bz2 niri-2aff1ec71a46487439d8785fd54c53dabe77023e.zip | |
ipc/socket: Support multiple requests
Diffstat (limited to 'src/ipc')
| -rw-r--r-- | src/ipc/client.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ipc/client.rs b/src/ipc/client.rs index 2eab7e15..4e0357d4 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -35,9 +35,9 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { Msg::OverviewState => Request::OverviewState, }; - let socket = Socket::connect().context("error connecting to the niri socket")?; + let mut socket = Socket::connect().context("error connecting to the niri socket")?; - let (reply, mut read_event) = socket + let reply = socket .send(request) .context("error communicating with niri")?; @@ -45,10 +45,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { Err(_) if !matches!(msg, Msg::Version) => { // If we got an error, it might be that the CLI is a different version from the running // niri instance. Request the running instance version to compare and print a message. - Socket::connect() - .and_then(|socket| socket.send(Request::Version)) - .ok() - .map(|(reply, _read_event)| reply) + socket.send(Request::Version).ok() } _ => None, }; @@ -392,6 +389,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { println!("Started reading events."); } + let mut read_event = socket.read_events(); loop { let event = read_event().context("error reading event from niri")?; |
