diff options
| author | rustysec <russ@infocyte.com> | 2024-05-22 16:16:03 -0700 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-26 21:29:22 +0400 |
| commit | ae7fb4c4f405aa0ff49930040d414581a812d938 (patch) | |
| tree | ed87cf6c57a3332f4077fae0dd49a0d0d2f97662 /src/ipc/server.rs | |
| parent | 4746a0da7dffde6befcb3c80609fa3d31bffc29c (diff) | |
| download | niri-ae7fb4c4f405aa0ff49930040d414581a812d938.tar.gz niri-ae7fb4c4f405aa0ff49930040d414581a812d938.tar.bz2 niri-ae7fb4c4f405aa0ff49930040d414581a812d938.zip | |
Add niri msg focused-output
Diffstat (limited to 'src/ipc/server.rs')
| -rw-r--r-- | src/ipc/server.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ipc/server.rs b/src/ipc/server.rs index 26958a7f..7987ca5c 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -208,6 +208,31 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply { let workspaces = result.map_err(|_| String::from("error getting workspace info"))?; Response::Workspaces(workspaces) } + Request::FocusedOutput => { + let (tx, rx) = async_channel::bounded(1); + ctx.event_loop.insert_idle(move |state| { + let active_output = state + .niri + .layout + .active_output() + .map(|output| output.name()); + + let output = active_output.and_then(|active_output| { + state + .backend + .ipc_outputs() + .lock() + .unwrap() + .get(&active_output) + .cloned() + }); + + let _ = tx.send_blocking(output); + }); + let result = rx.recv().await; + let output = result.map_err(|_| String::from("error getting active output info"))?; + Response::FocusedOutput(output) + } }; Ok(response) |
