diff options
| -rw-r--r-- | src/ipc/client.rs | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/src/ipc/client.rs b/src/ipc/client.rs index fcbf4b8c..472daab2 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -3,7 +3,7 @@ use niri_config::OutputName; use niri_ipc::socket::Socket; use niri_ipc::{ Event, KeyboardLayouts, LogicalOutput, Mode, Output, OutputConfigChanged, Request, Response, - Transform, + Transform, Window, }; use serde_json::json; @@ -144,19 +144,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { } if let Some(window) = window { - println!("Focused window:"); - - if let Some(title) = window.title { - println!(" Title: \"{title}\""); - } else { - println!(" Title: (unset)"); - } - - if let Some(app_id) = window.app_id { - println!(" App ID: \"{app_id}\""); - } else { - println!(" App ID: (unset)"); - } + print_window(&window); } else { println!("No window is focused."); } @@ -176,27 +164,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { windows.sort_unstable_by(|a, b| a.id.cmp(&b.id)); for window in windows { - let focused = if window.is_focused { " (focused)" } else { "" }; - println!("Window ID {}:{focused}", window.id); - - if let Some(title) = window.title { - println!(" Title: \"{title}\""); - } else { - println!(" Title: (unset)"); - } - - if let Some(app_id) = window.app_id { - println!(" App ID: \"{app_id}\""); - } else { - println!(" App ID: (unset)"); - } - - if let Some(workspace_id) = window.workspace_id { - println!(" Workspace ID: {workspace_id}"); - } else { - println!(" Workspace ID: (none)"); - } - + print_window(&window); println!(); } } @@ -464,3 +432,26 @@ fn print_output(output: Output) -> anyhow::Result<()> { } Ok(()) } + +fn print_window(window: &Window) { + let focused = if window.is_focused { " (focused)" } else { "" }; + println!("Window ID {}:{focused}", window.id); + + if let Some(title) = &window.title { + println!(" Title: \"{title}\""); + } else { + println!(" Title: (unset)"); + } + + if let Some(app_id) = &window.app_id { + println!(" App ID: \"{app_id}\""); + } else { + println!(" App ID: (unset)"); + } + + if let Some(workspace_id) = window.workspace_id { + println!(" Workspace ID: {workspace_id}"); + } else { + println!(" Workspace ID: (none)"); + } +} |
