aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-05-05 12:50:18 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-05-05 12:50:18 +0400
commitea590918696709b0586eb1941b4829ffc5a46e94 (patch)
tree3432d7e56a5beeb7d5c5213f747633906c3f6e70
parent2e4a2e13b175fcbb0fef58214f7de5b60775214a (diff)
downloadniri-ea590918696709b0586eb1941b4829ffc5a46e94.tar.gz
niri-ea590918696709b0586eb1941b4829ffc5a46e94.tar.bz2
niri-ea590918696709b0586eb1941b4829ffc5a46e94.zip
Print message when output was not found
-rw-r--r--niri-ipc/src/lib.rs11
-rw-r--r--src/ipc/client.rs15
-rw-r--r--src/ipc/server.rs13
3 files changed, 33 insertions, 6 deletions
diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs
index db2d7a0f..bf67acd7 100644
--- a/niri-ipc/src/lib.rs
+++ b/niri-ipc/src/lib.rs
@@ -58,6 +58,8 @@ pub enum Response {
Outputs(HashMap<String, Output>),
/// Information about the focused window.
FocusedWindow(Option<Window>),
+ /// Output configuration change result.
+ OutputConfigChanged(OutputConfigChanged),
}
/// Actions that niri can perform.
@@ -456,6 +458,15 @@ pub struct Window {
pub app_id: Option<String>,
}
+/// Output configuration change result.
+#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
+pub enum OutputConfigChanged {
+ /// The target output was connected and the change was applied.
+ Applied,
+ /// The target output was not found, the change will be applied when it is connected.
+ OutputWasMissing,
+}
+
impl FromStr for SizeChange {
type Err = &'static str;
diff --git a/src/ipc/client.rs b/src/ipc/client.rs
index 3aa5eb22..4709f57a 100644
--- a/src/ipc/client.rs
+++ b/src/ipc/client.rs
@@ -1,5 +1,7 @@
use anyhow::{anyhow, bail, Context};
-use niri_ipc::{LogicalOutput, Mode, Output, Request, Response, Socket, Transform};
+use niri_ipc::{
+ LogicalOutput, Mode, Output, OutputConfigChanged, Request, Response, Socket, Transform,
+};
use serde_json::json;
use crate::cli::Msg;
@@ -241,10 +243,15 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
bail!("unexpected response: expected Handled, got {response:?}");
};
}
- Msg::Output { .. } => {
- let Response::Handled = response else {
- bail!("unexpected response: expected Handled, got {response:?}");
+ Msg::Output { output, .. } => {
+ let Response::OutputConfigChanged(response) = response else {
+ bail!("unexpected response: expected OutputConfigChanged, got {response:?}");
};
+
+ if response == OutputConfigChanged::OutputWasMissing {
+ println!("Output \"{output}\" is not connected.");
+ println!("The change will apply when it is connected.");
+ }
}
}
diff --git a/src/ipc/server.rs b/src/ipc/server.rs
index 59f929d8..251f70bc 100644
--- a/src/ipc/server.rs
+++ b/src/ipc/server.rs
@@ -8,7 +8,7 @@ use calloop::io::Async;
use directories::BaseDirs;
use futures_util::io::{AsyncReadExt, BufReader};
use futures_util::{AsyncBufReadExt, AsyncWriteExt};
-use niri_ipc::{Reply, Request, Response};
+use niri_ipc::{OutputConfigChanged, Reply, Request, Response};
use smithay::desktop::Window;
use smithay::reexports::calloop::generic::Generic;
use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction};
@@ -170,10 +170,19 @@ fn process(ctx: &ClientCtx, request: Request) -> Reply {
Response::Handled
}
Request::Output { output, action } => {
+ let ipc_outputs = ctx.ipc_outputs.lock().unwrap();
+ let response = if ipc_outputs.contains_key(&output) {
+ OutputConfigChanged::Applied
+ } else {
+ OutputConfigChanged::OutputWasMissing
+ };
+ drop(ipc_outputs);
+
ctx.event_loop.insert_idle(move |state| {
state.apply_transient_output_config(&output, action);
});
- Response::Handled
+
+ Response::OutputConfigChanged(response)
}
};