diff options
| author | Merlijn <32853531+ToxicMushroom@users.noreply.github.com> | 2025-10-29 07:10:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-29 09:10:38 +0300 |
| commit | 6a2c6261df130cccb5262eddf71d40b2fffcf8f9 (patch) | |
| tree | 48639aef4ebddbc315234b925954c5cc768d0f1c /src/ipc/client.rs | |
| parent | e6f3c538da0c646bda43fcde7ef7dc3b771e0c8b (diff) | |
| download | niri-6a2c6261df130cccb5262eddf71d40b2fffcf8f9.tar.gz niri-6a2c6261df130cccb5262eddf71d40b2fffcf8f9.tar.bz2 niri-6a2c6261df130cccb5262eddf71d40b2fffcf8f9.zip | |
Add support for custom modes and modelines. (#2479)
* Implement custom modes and modelines
Co-authored-by: ToxicMushroom <32853531+ToxicMushroom@users.noreply.github.com>
* fixes
* refactor mode and modeline kdl parsers.
* add IPC parse checks
* refactor: address feedback
* fix: add missing > 0 refresh rate check
* move things around
* fixes
* wiki fixes
---------
Co-authored-by: Christian Meissl <meissl.christian@gmail.com>
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/ipc/client.rs')
| -rw-r--r-- | src/ipc/client.rs | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/ipc/client.rs b/src/ipc/client.rs index 3c7b27a9..8fea1d2b 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -526,6 +526,7 @@ fn print_output(output: Output) -> anyhow::Result<()> { physical_size, modes, current_mode, + is_custom_mode, vrr_supported, vrr_enabled, logical, @@ -534,6 +535,26 @@ fn print_output(output: Output) -> anyhow::Result<()> { let serial = serial.as_deref().unwrap_or("Unknown"); println!(r#"Output "{make} {model} {serial}" ({name})"#); + let print_qualifier = |is_preferred: bool, is_current: bool, is_custom_mode: bool| { + let mut qualifier = Vec::new(); + if is_current { + qualifier.push("current"); + if is_custom_mode { + qualifier.push("custom"); + }; + }; + + if is_preferred { + qualifier.push("preferred"); + }; + + if qualifier.is_empty() { + String::new() + } else { + format!(" ({})", qualifier.join(", ")) + } + }; + if let Some(current) = current_mode { let mode = *modes .get(current) @@ -545,8 +566,10 @@ fn print_output(output: Output) -> anyhow::Result<()> { is_preferred, } = mode; let refresh = refresh_rate as f64 / 1000.; - let preferred = if is_preferred { " (preferred)" } else { "" }; - println!(" Current mode: {width}x{height} @ {refresh:.3} Hz{preferred}"); + + // This is technically the current mode, but the println below already specifies that. + let qualifier = print_qualifier(is_preferred, false, is_custom_mode); + println!(" Current mode: {width}x{height} @ {refresh:.3} Hz{qualifier}"); } else { println!(" Disabled"); } @@ -601,12 +624,7 @@ fn print_output(output: Output) -> anyhow::Result<()> { let refresh = refresh_rate as f64 / 1000.; let is_current = Some(idx) == current_mode; - let qualifier = match (is_current, is_preferred) { - (true, true) => " (current, preferred)", - (true, false) => " (current)", - (false, true) => " (preferred)", - (false, false) => "", - }; + let qualifier = print_qualifier(is_preferred, is_current, is_custom_mode); println!(" {width}x{height}@{refresh:.3}{qualifier}"); } |
