niri
Clone
https://git.tahinli.com/Tahinli/niri.git
0 watching·0 forks·Rust·GPL-3.0·12.1 MiB·055a94d·Ivan Molodetskikh·1 year ago·2247 commits
| 1 | use std::io::ErrorKind; |
| 2 | use std::iter::Peekable; |
| 3 | use std::slice; |
| 4 | |
| 5 | use anyhow::{anyhow, bail, Context}; |
| 6 | use niri_config::OutputName; |
| 7 | use niri_ipc::socket::Socket; |
| 8 | use niri_ipc::{ |
| 9 | Event, KeyboardLayouts, LogicalOutput, Mode, Output, OutputConfigChanged, Overview, Request, |
| 10 | Response, Transform, Window, |
| 11 | }; |
| 12 | use serde_json::json; |
| 13 | |
| 14 | use crate::cli::Msg; |
| 15 | use crate::utils::version; |
| 16 | |
| 17 | pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { |
| 18 | let request = match &msg { |
| 19 | Msg::Version => Request::Version, |
| 20 | Msg::Outputs => Request::Outputs, |
| 21 | Msg::FocusedWindow => Request::FocusedWindow, |
| 22 | Msg::FocusedOutput => Request::FocusedOutput, |
| 23 | Msg::PickWindow => Request::PickWindow, |
| 24 | Msg::PickColor => Request::PickColor, |
| 25 | Msg::Action { action } => Request::Action(action.clone()), |
| 26 | Msg::Output { output, action } => Request::Output { |
| 27 | output: output.clone(), |
| 28 | action: action.clone(), |
| 29 | }, |
| 30 | Msg::Workspaces => Request::Workspaces, |
| 31 | Msg::Windows => Request::Windows, |
| 32 | Msg::Layers => Request::Layers, |
| 33 | Msg::KeyboardLayouts => Request::KeyboardLayouts, |
| 34 | Msg::EventStream => Request::EventStream, |
| 35 | Msg::RequestError => Request::ReturnError, |
| 36 | Msg::OverviewState => Request::OverviewState, |
| 37 | }; |
| 38 | |
| 39 | let mut socket = Socket::connect().context("error connecting to the niri socket")?; |
| 40 | |
| 41 | let result = socket.send(request); |
| 42 | |
| 43 | // For errors that can be caused by a version mismatch between the running niri instance and |
| 44 | // the niri msg CLI, we will try to fetch and compare the versions. |
| 45 | let check_compositor_version = match &result { |
| 46 | Err(err) => { |
| 47 | // Response JSON parsing errors. |
| 48 | matches!( |
| 49 | err.kind(), |
| 50 | ErrorKind::InvalidData | ErrorKind::UnexpectedEof |
| 51 | ) |
| 52 | } |
| 53 | // Error returned from niri. |
| 54 | Ok(Err(_)) => true, |
| 55 | _ => false, |
| 56 | }; |
| 57 | |
| 58 | let compositor_version = if check_compositor_version && !matches!(msg, Msg::Version) { |
| 59 | // Reconnect to support older niri versions with one request per connection. |
| 60 | Socket::connect() |
| 61 | .and_then(|mut socket| socket.send(Request::Version)) |
| 62 | .ok() |
| 63 | } else { |
| 64 | None |
| 65 | }; |
| 66 | |
| 67 | // Default SIGPIPE so that our prints don't panic on stdout closing. |
| 68 | unsafe { |
| 69 | libc::signal(libc::SIGPIPE, libc::SIG_DFL); |
| 70 | } |
| 71 | |
| 72 | // Check for CLI-server version mismatch to add helpful context. |
| 73 | match compositor_version { |
| 74 | Some(Ok(Response::Version(compositor_version))) => { |
| 75 | let cli_version = version(); |
| 76 | if cli_version != compositor_version { |
| 77 | eprintln!("Running niri compositor has a different version from the niri CLI:"); |
| 78 | eprintln!("Compositor version: {compositor_version}"); |
| 79 | eprintln!("CLI version: {cli_version}"); |
| 80 | eprintln!("Did you forget to restart niri after an update?"); |
| 81 | eprintln!(); |
| 82 | } |
| 83 | } |
| 84 | Some(_) => { |
| 85 | eprintln!("Unable to get the running niri compositor version."); |
| 86 | eprintln!("Did you forget to restart niri after an update?"); |
| 87 | eprintln!(); |
| 88 | } |
| 89 | None => { |
| 90 | // Communication error, or the original request was already a version request, or the |
| 91 | // original request had succeeded. Don't add irrelevant context. |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | let reply = result.context("error communicating with niri")?; |
| 96 | let response = reply.map_err(|err_msg| anyhow!(err_msg).context("niri returned an error"))?; |
| 97 | |
| 98 | match msg { |
| 99 | Msg::RequestError => { |
| 100 | bail!("unexpected response: expected an error, got {response:?}"); |
| 101 | } |
| 102 | Msg::Version => { |
| 103 | let Response::Version(compositor_version) = response else { |
| 104 | bail!("unexpected response: expected Version, got {response:?}"); |
| 105 | }; |
| 106 | |
| 107 | let cli_version = version(); |
| 108 | |
| 109 | if json { |
| 110 | println!( |
| 111 | "{}", |
| 112 | json!({ |
| 113 | "compositor": compositor_version, |
| 114 | "cli": cli_version, |
| 115 | }) |
| 116 | ); |
| 117 | return Ok(()); |
| 118 | } |
| 119 | |
| 120 | if cli_version != compositor_version { |
| 121 | eprintln!("Running niri compositor has a different version from the niri CLI."); |
| 122 | eprintln!("Did you forget to restart niri after an update?"); |
| 123 | eprintln!(); |
| 124 | } |
| 125 | |
| 126 | println!("Compositor version: {compositor_version}"); |
| 127 | println!("CLI version: {cli_version}"); |
| 128 | } |
| 129 | Msg::Outputs => { |
| 130 | let Response::Outputs(outputs) = response else { |
| 131 | bail!("unexpected response: expected Outputs, got {response:?}"); |
| 132 | }; |
| 133 | |
| 134 | if json { |
| 135 | let output = |
| 136 | serde_json::to_string(&outputs).context("error formatting response")?; |
| 137 | println!("{output}"); |
| 138 | return Ok(()); |
| 139 | } |
| 140 | |
| 141 | let mut outputs = outputs |
| 142 | .into_values() |
| 143 | .map(|out| (OutputName::from_ipc_output(&out), out)) |
| 144 | .collect::<Vec<_>>(); |
| 145 | outputs.sort_unstable_by(|a, b| a.0.compare(&b.0)); |
| 146 | |
| 147 | for (_name, output) in outputs.into_iter() { |
| 148 | print_output(output)?; |
| 149 | println!(); |
| 150 | } |
| 151 | } |
| 152 | Msg::FocusedWindow => { |
| 153 | let Response::FocusedWindow(window) = response else { |
| 154 | bail!("unexpected response: expected FocusedWindow, got {response:?}"); |
| 155 | }; |
| 156 | |
| 157 | if json { |
| 158 | let window = serde_json::to_string(&window).context("error formatting response")?; |
| 159 | println!("{window}"); |
| 160 | return Ok(()); |
| 161 | } |
| 162 | |
| 163 | if let Some(window) = window { |
| 164 | print_window(&window); |
| 165 | } else { |
| 166 | println!("No window is focused."); |
| 167 | } |
| 168 | } |
| 169 | Msg::Windows => { |
| 170 | let Response::Windows(mut windows) = response else { |
| 171 | bail!("unexpected response: expected Windows, got {response:?}"); |
| 172 | }; |
| 173 | |
| 174 | if json { |
| 175 | let windows = |
| 176 | serde_json::to_string(&windows).context("error formatting response")?; |
| 177 | println!("{windows}"); |
| 178 | return Ok(()); |
| 179 | } |
| 180 | |
| 181 | windows.sort_unstable_by(|a, b| a.id.cmp(&b.id)); |
| 182 | |
| 183 | for window in windows { |
| 184 | print_window(&window); |
| 185 | println!(); |
| 186 | } |
| 187 | } |
| 188 | Msg::Layers => { |
| 189 | let Response::Layers(mut layers) = response else { |
| 190 | bail!("unexpected response: expected Layers, got {response:?}"); |
| 191 | }; |
| 192 | |
| 193 | if json { |
| 194 | let layers = serde_json::to_string(&layers).context("error formatting response")?; |
| 195 | println!("{layers}"); |
| 196 | return Ok(()); |
| 197 | } |
| 198 | |
| 199 | layers.sort_by(|a, b| { |
| 200 | Ord::cmp(&a.output, &b.output) |
| 201 | .then_with(|| Ord::cmp(&a.layer, &b.layer)) |
| 202 | .then_with(|| Ord::cmp(&a.namespace, &b.namespace)) |
| 203 | }); |
| 204 | let mut iter = layers.iter().peekable(); |
| 205 | |
| 206 | let print = |surface: &niri_ipc::LayerSurface| { |
| 207 | println!(" Surface:"); |
| 208 | println!(" Namespace: \"{}\"", &surface.namespace); |
| 209 | |
| 210 | let interactivity = match surface.keyboard_interactivity { |
| 211 | niri_ipc::LayerSurfaceKeyboardInteractivity::None => "none", |
| 212 | niri_ipc::LayerSurfaceKeyboardInteractivity::Exclusive => "exclusive", |
| 213 | niri_ipc::LayerSurfaceKeyboardInteractivity::OnDemand => "on-demand", |
| 214 | }; |
| 215 | println!(" Keyboard interactivity: {interactivity}"); |
| 216 | }; |
| 217 | |
| 218 | let print_layer = |iter: &mut Peekable<slice::Iter<niri_ipc::LayerSurface>>, |
| 219 | output: &str, |
| 220 | layer| { |
| 221 | let mut empty = true; |
| 222 | while let Some(surface) = iter.next_if(|s| s.output == output && s.layer == layer) { |
| 223 | empty = false; |
| 224 | println!(); |
| 225 | print(surface); |
| 226 | } |
| 227 | if empty { |
| 228 | println!(" (empty)\n"); |
| 229 | } else { |
| 230 | println!(); |
| 231 | } |
| 232 | }; |
| 233 | |
| 234 | while let Some(surface) = iter.peek() { |
| 235 | let output = &surface.output; |
| 236 | println!("Output \"{output}\":"); |
| 237 | |
| 238 | print!(" Background layer:"); |
| 239 | print_layer(&mut iter, output, niri_ipc::Layer::Background); |
| 240 | |
| 241 | print!(" Bottom layer:"); |
| 242 | print_layer(&mut iter, output, niri_ipc::Layer::Bottom); |
| 243 | |
| 244 | print!(" Top layer:"); |
| 245 | print_layer(&mut iter, output, niri_ipc::Layer::Top); |
| 246 | |
| 247 | print!(" Overlay layer:"); |
| 248 | print_layer(&mut iter, output, niri_ipc::Layer::Overlay); |
| 249 | } |
| 250 | } |
| 251 | Msg::FocusedOutput => { |
| 252 | let Response::FocusedOutput(output) = response else { |
| 253 | bail!("unexpected response: expected FocusedOutput, got {response:?}"); |
| 254 | }; |
| 255 | |
| 256 | if json { |
| 257 | let output = serde_json::to_string(&output).context("error formatting response")?; |
| 258 | println!("{output}"); |
| 259 | return Ok(()); |
| 260 | } |
| 261 | |
| 262 | if let Some(output) = output { |
| 263 | print_output(output)?; |
| 264 | } else { |
| 265 | println!("No output is focused."); |
| 266 | } |
| 267 | } |
| 268 | Msg::PickWindow => { |
| 269 | let Response::PickedWindow(window) = response else { |
| 270 | bail!("unexpected response: expected PickedWindow, got {response:?}"); |
| 271 | }; |
| 272 | |
| 273 | if json { |
| 274 | let window = serde_json::to_string(&window).context("error formatting response")?; |
| 275 | println!("{window}"); |
| 276 | return Ok(()); |
| 277 | } |
| 278 | |
| 279 | if let Some(window) = window { |
| 280 | print_window(&window); |
| 281 | } else { |
| 282 | println!("No window selected."); |
| 283 | } |
| 284 | } |
| 285 | Msg::PickColor => { |
| 286 | let Response::PickedColor(color) = response else { |
| 287 | bail!("unexpected response: expected PickedColor, got {response:?}"); |
| 288 | }; |
| 289 | |
| 290 | if json { |
| 291 | let color = serde_json::to_string(&color).context("error formatting response")?; |
| 292 | println!("{color}"); |
| 293 | return Ok(()); |
| 294 | } |
| 295 | |
| 296 | if let Some(color) = color { |
| 297 | let [r, g, b] = color.rgb.map(|v| (v.clamp(0., 1.) * 255.).round() as u8); |
| 298 | |
| 299 | println!("Picked color: rgb({r}, {g}, {b})",); |
| 300 | println!("Hex: #{r:02x}{g:02x}{b:02x}"); |
| 301 | } else { |
| 302 | println!("No color was picked."); |
| 303 | } |
| 304 | } |
| 305 | Msg::Action { .. } => { |
| 306 | let Response::Handled = response else { |
| 307 | bail!("unexpected response: expected Handled, got {response:?}"); |
| 308 | }; |
| 309 | } |
| 310 | Msg::Output { output, .. } => { |
| 311 | let Response::OutputConfigChanged(response) = response else { |
| 312 | bail!("unexpected response: expected OutputConfigChanged, got {response:?}"); |
| 313 | }; |
| 314 | |
| 315 | if json { |
| 316 | let response = |
| 317 | serde_json::to_string(&response).context("error formatting response")?; |
| 318 | println!("{response}"); |
| 319 | return Ok(()); |
| 320 | } |
| 321 | |
| 322 | if response == OutputConfigChanged::OutputWasMissing { |
| 323 | println!("Output \"{output}\" is not connected."); |
| 324 | println!("The change will apply when it is connected."); |
| 325 | } |
| 326 | } |
| 327 | Msg::Workspaces => { |
| 328 | let Response::Workspaces(mut response) = response else { |
| 329 | bail!("unexpected response: expected Workspaces, got {response:?}"); |
| 330 | }; |
| 331 | |
| 332 | if json { |
| 333 | let response = |
| 334 | serde_json::to_string(&response).context("error formatting response")?; |
| 335 | println!("{response}"); |
| 336 | return Ok(()); |
| 337 | } |
| 338 | |
| 339 | if response.is_empty() { |
| 340 | println!("No workspaces."); |
| 341 | return Ok(()); |
| 342 | } |
| 343 | |
| 344 | response.sort_by_key(|ws| ws.idx); |
| 345 | response.sort_by(|a, b| a.output.cmp(&b.output)); |
| 346 | |
| 347 | let mut current_output = if let Some(output) = response[0].output.as_deref() { |
| 348 | println!("Output \"{output}\":"); |
| 349 | Some(output) |
| 350 | } else { |
| 351 | println!("No output:"); |
| 352 | None |
| 353 | }; |
| 354 | |
| 355 | for ws in &response { |
| 356 | if ws.output.as_deref() != current_output { |
| 357 | let output = ws.output.as_deref().context( |
| 358 | "invalid response: workspace with no output \ |
| 359 | following a workspace with an output", |
| 360 | )?; |
| 361 | current_output = Some(output); |
| 362 | println!("\nOutput \"{output}\":"); |
| 363 | } |
| 364 | |
| 365 | let is_active = if ws.is_active { " * " } else { " " }; |
| 366 | let idx = ws.idx; |
| 367 | let name = if let Some(name) = ws.name.as_deref() { |
| 368 | format!(" \"{name}\"") |
| 369 | } else { |
| 370 | String::new() |
| 371 | }; |
| 372 | println!("{is_active}{idx}{name}"); |
| 373 | } |
| 374 | } |
| 375 | Msg::KeyboardLayouts => { |
| 376 | let Response::KeyboardLayouts(response) = response else { |
| 377 | bail!("unexpected response: expected KeyboardLayouts, got {response:?}"); |
| 378 | }; |
| 379 | |
| 380 | if json { |
| 381 | let response = |
| 382 | serde_json::to_string(&response).context("error formatting response")?; |
| 383 | println!("{response}"); |
| 384 | return Ok(()); |
| 385 | } |
| 386 | |
| 387 | let KeyboardLayouts { names, current_idx } = response; |
| 388 | let current_idx = usize::from(current_idx); |
| 389 | |
| 390 | println!("Keyboard layouts:"); |
| 391 | for (idx, name) in names.iter().enumerate() { |
| 392 | let is_active = if idx == current_idx { " * " } else { " " }; |
| 393 | println!("{is_active}{idx} {name}"); |
| 394 | } |
| 395 | } |
| 396 | Msg::EventStream => { |
| 397 | let Response::Handled = response else { |
| 398 | bail!("unexpected response: expected Handled, got {response:?}"); |
| 399 | }; |
| 400 | |
| 401 | if !json { |
| 402 | println!("Started reading events."); |
| 403 | } |
| 404 | |
| 405 | let mut read_event = socket.read_events(); |
| 406 | loop { |
| 407 | let event = read_event().context("error reading event from niri")?; |
| 408 | |
| 409 | if json { |
| 410 | let event = serde_json::to_string(&event).context("error formatting event")?; |
| 411 | println!("{event}"); |
| 412 | continue; |
| 413 | } |
| 414 | |
| 415 | match event { |
| 416 | Event::WorkspacesChanged { workspaces } => { |
| 417 | println!("Workspaces changed: {workspaces:?}"); |
| 418 | } |
| 419 | Event::WorkspaceUrgencyChanged { id, urgent } => { |
| 420 | println!("Workspace {id}: urgency changed to {urgent}"); |
| 421 | } |
| 422 | Event::WorkspaceActivated { id, focused } => { |
| 423 | let word = if focused { "focused" } else { "activated" }; |
| 424 | println!("Workspace {word}: {id}"); |
| 425 | } |
| 426 | Event::WorkspaceActiveWindowChanged { |
| 427 | workspace_id, |
| 428 | active_window_id, |
| 429 | } => { |
| 430 | println!( |
| 431 | "Workspace {workspace_id}: \ |
| 432 | active window changed to {active_window_id:?}" |
| 433 | ); |
| 434 | } |
| 435 | Event::WindowsChanged { windows } => { |
| 436 | println!("Windows changed: {windows:?}"); |
| 437 | } |
| 438 | Event::WindowOpenedOrChanged { window } => { |
| 439 | println!("Window opened or changed: {window:?}"); |
| 440 | } |
| 441 | Event::WindowClosed { id } => { |
| 442 | println!("Window closed: {id}"); |
| 443 | } |
| 444 | Event::WindowFocusChanged { id } => { |
| 445 | println!("Window focus changed: {id:?}"); |
| 446 | } |
| 447 | Event::WindowUrgencyChanged { id, urgent } => { |
| 448 | println!("Window {id}: urgency changed to {urgent}"); |
| 449 | } |
| 450 | Event::KeyboardLayoutsChanged { keyboard_layouts } => { |
| 451 | println!("Keyboard layouts changed: {keyboard_layouts:?}"); |
| 452 | } |
| 453 | Event::KeyboardLayoutSwitched { idx } => { |
| 454 | println!("Keyboard layout switched: {idx}"); |
| 455 | } |
| 456 | Event::OverviewOpenedOrClosed { is_open: opened } => { |
| 457 | println!("Overview toggled: {opened}"); |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | Msg::OverviewState => { |
| 463 | let Response::OverviewState(response) = response else { |
| 464 | bail!("unexpected response: expected Overview, got {response:?}"); |
| 465 | }; |
| 466 | |
| 467 | if json { |
| 468 | let response = |
| 469 | serde_json::to_string(&response).context("error formatting response")?; |
| 470 | println!("{response}"); |
| 471 | return Ok(()); |
| 472 | } |
| 473 | |
| 474 | let Overview { is_open } = response; |
| 475 | if is_open { |
| 476 | println!("Overview is open."); |
| 477 | } else { |
| 478 | println!("Overview is closed."); |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | Ok(()) |
| 484 | } |
| 485 | |
| 486 | fn print_output(output: Output) -> anyhow::Result<()> { |
| 487 | let Output { |
| 488 | name, |
| 489 | make, |
| 490 | model, |
| 491 | serial, |
| 492 | physical_size, |
| 493 | modes, |
| 494 | current_mode, |
| 495 | vrr_supported, |
| 496 | vrr_enabled, |
| 497 | logical, |
| 498 | } = output; |
| 499 | |
| 500 | let serial = serial.as_deref().unwrap_or("Unknown"); |
| 501 | println!(r#"Output "{make} {model} {serial}" ({name})"#); |
| 502 | |
| 503 | if let Some(current) = current_mode { |
| 504 | let mode = *modes |
| 505 | .get(current) |
| 506 | .context("invalid response: current mode does not exist")?; |
| 507 | let Mode { |
| 508 | width, |
| 509 | height, |
| 510 | refresh_rate, |
| 511 | is_preferred, |
| 512 | } = mode; |
| 513 | let refresh = refresh_rate as f64 / 1000.; |
| 514 | let preferred = if is_preferred { " (preferred)" } else { "" }; |
| 515 | println!(" Current mode: {width}x{height} @ {refresh:.3} Hz{preferred}"); |
| 516 | } else { |
| 517 | println!(" Disabled"); |
| 518 | } |
| 519 | |
| 520 | if vrr_supported { |
| 521 | let enabled = if vrr_enabled { "enabled" } else { "disabled" }; |
| 522 | println!(" Variable refresh rate: supported, {enabled}"); |
| 523 | } else { |
| 524 | println!(" Variable refresh rate: not supported"); |
| 525 | } |
| 526 | |
| 527 | if let Some((width, height)) = physical_size { |
| 528 | println!(" Physical size: {width}x{height} mm"); |
| 529 | } else { |
| 530 | println!(" Physical size: unknown"); |
| 531 | } |
| 532 | |
| 533 | if let Some(logical) = logical { |
| 534 | let LogicalOutput { |
| 535 | x, |
| 536 | y, |
| 537 | width, |
| 538 | height, |
| 539 | scale, |
| 540 | transform, |
| 541 | } = logical; |
| 542 | println!(" Logical position: {x}, {y}"); |
| 543 | println!(" Logical size: {width}x{height}"); |
| 544 | println!(" Scale: {scale}"); |
| 545 | |
| 546 | let transform = match transform { |
| 547 | Transform::Normal => "normal", |
| 548 | Transform::_90 => "90° counter-clockwise", |
| 549 | Transform::_180 => "180°", |
| 550 | Transform::_270 => "270° counter-clockwise", |
| 551 | Transform::Flipped => "flipped horizontally", |
| 552 | Transform::Flipped90 => "90° counter-clockwise, flipped horizontally", |
| 553 | Transform::Flipped180 => "flipped vertically", |
| 554 | Transform::Flipped270 => "270° counter-clockwise, flipped horizontally", |
| 555 | }; |
| 556 | println!(" Transform: {transform}"); |
| 557 | } |
| 558 | |
| 559 | println!(" Available modes:"); |
| 560 | for (idx, mode) in modes.into_iter().enumerate() { |
| 561 | let Mode { |
| 562 | width, |
| 563 | height, |
| 564 | refresh_rate, |
| 565 | is_preferred, |
| 566 | } = mode; |
| 567 | let refresh = refresh_rate as f64 / 1000.; |
| 568 | |
| 569 | let is_current = Some(idx) == current_mode; |
| 570 | let qualifier = match (is_current, is_preferred) { |
| 571 | (true, true) => " (current, preferred)", |
| 572 | (true, false) => " (current)", |
| 573 | (false, true) => " (preferred)", |
| 574 | (false, false) => "", |
| 575 | }; |
| 576 | |
| 577 | println!(" {width}x{height}@{refresh:.3}{qualifier}"); |
| 578 | } |
| 579 | Ok(()) |
| 580 | } |
| 581 | |
| 582 | fn print_window(window: &Window) { |
| 583 | let focused = if window.is_focused { " (focused)" } else { "" }; |
| 584 | let urgent = if window.is_urgent { " (urgent)" } else { "" }; |
| 585 | println!("Window ID {}:{focused}{urgent}", window.id); |
| 586 | |
| 587 | if let Some(title) = &window.title { |
| 588 | println!(" Title: \"{title}\""); |
| 589 | } else { |
| 590 | println!(" Title: (unset)"); |
| 591 | } |
| 592 | |
| 593 | if let Some(app_id) = &window.app_id { |
| 594 | println!(" App ID: \"{app_id}\""); |
| 595 | } else { |
| 596 | println!(" App ID: (unset)"); |
| 597 | } |
| 598 | |
| 599 | println!( |
| 600 | " Is floating: {}", |
| 601 | if window.is_floating { "yes" } else { "no" } |
| 602 | ); |
| 603 | |
| 604 | if let Some(pid) = window.pid { |
| 605 | println!(" PID: {pid}"); |
| 606 | } else { |
| 607 | println!(" PID: (unknown)"); |
| 608 | } |
| 609 | |
| 610 | if let Some(workspace_id) = window.workspace_id { |
| 611 | println!(" Workspace ID: {workspace_id}"); |
| 612 | } else { |
| 613 | println!(" Workspace ID: (none)"); |
| 614 | } |
| 615 | } |