aboutsummaryrefslogtreecommitdiff
path: root/src/ipc
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-09-03 12:13:04 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-09-03 13:48:08 +0300
commitf0157e03e72714264e684295fac226e2046f0b38 (patch)
tree7bfd198f59697704c5464c8498d3f8d7ff80131d /src/ipc
parent4b7c16b04a7c80f5f9b6fcbc4a1d8c9448dffbdb (diff)
downloadniri-f0157e03e72714264e684295fac226e2046f0b38.tar.gz
niri-f0157e03e72714264e684295fac226e2046f0b38.tar.bz2
niri-f0157e03e72714264e684295fac226e2046f0b38.zip
Use libdisplay-info for make/model/serial parsing, implement throughout
Diffstat (limited to 'src/ipc')
-rw-r--r--src/ipc/client.rs12
-rw-r--r--src/ipc/server.rs3
2 files changed, 9 insertions, 6 deletions
diff --git a/src/ipc/client.rs b/src/ipc/client.rs
index 0f4d6228..1b44a987 100644
--- a/src/ipc/client.rs
+++ b/src/ipc/client.rs
@@ -122,8 +122,8 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
let mut outputs = outputs.into_iter().collect::<Vec<_>>();
outputs.sort_unstable_by(|a, b| a.0.cmp(&b.0));
- for (connector, output) in outputs.into_iter() {
- print_output(connector, output)?;
+ for (_name, output) in outputs.into_iter() {
+ print_output(output)?;
println!();
}
}
@@ -207,7 +207,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
}
if let Some(output) = output {
- print_output(output.name.clone(), output)?;
+ print_output(output)?;
} else {
println!("No output is focused.");
}
@@ -364,11 +364,12 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
Ok(())
}
-fn print_output(connector: String, output: Output) -> anyhow::Result<()> {
+fn print_output(output: Output) -> anyhow::Result<()> {
let Output {
name,
make,
model,
+ serial,
physical_size,
modes,
current_mode,
@@ -377,7 +378,8 @@ fn print_output(connector: String, output: Output) -> anyhow::Result<()> {
logical,
} = output;
- println!(r#"Output "{connector}" ({make} - {model} - {name})"#);
+ let serial = serial.as_deref().unwrap_or("Unknown");
+ println!(r#"Output "{make} {model} {serial}" ({name})"#);
if let Some(current) = current_mode {
let mode = *modes
diff --git a/src/ipc/server.rs b/src/ipc/server.rs
index 6990cd41..aeb0fcf0 100644
--- a/src/ipc/server.rs
+++ b/src/ipc/server.rs
@@ -13,6 +13,7 @@ use calloop::io::Async;
use directories::BaseDirs;
use futures_util::io::{AsyncReadExt, BufReader};
use futures_util::{select_biased, AsyncBufReadExt, AsyncWrite, AsyncWriteExt, FutureExt as _};
+use niri_config::OutputName;
use niri_ipc::state::{EventStreamState, EventStreamStatePart as _};
use niri_ipc::{Event, KeyboardLayouts, OutputConfigChanged, Reply, Request, Response, Workspace};
use smithay::input::keyboard::XkbContextHandler;
@@ -296,7 +297,7 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
let ipc_outputs = ctx.ipc_outputs.lock().unwrap();
let found = ipc_outputs
.values()
- .any(|o| o.name.eq_ignore_ascii_case(&output));
+ .any(|o| OutputName::from_ipc_output(o).matches(&output));
let response = if found {
OutputConfigChanged::Applied
} else {