From 567a1002737294103c8d67659e126165101fc3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 25 Oct 2026 07:44:34 +0300 Subject: [PATCH] input: add wake-monitors-on-input option Setting `wake-monitors-on-input false` keeps the monitors off after power-off-monitors until the power-on-monitors action runs, instead of waking them on any input. Binds keep working while they are off. The default stays true, matching the previous behavior. --- docs/wiki/Configuration:-Input.md | 18 ++++++++++++++++++ niri-config/src/input.rs | 30 +++++++++++++++++++++++++++++- niri-config/src/lib.rs | 2 ++ src/input/mod.rs | 7 +++++-- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/docs/wiki/Configuration:-Input.md b/docs/wiki/Configuration:-Input.md index af645910..4e6777a3 100644 --- a/docs/wiki/Configuration:-Input.md +++ b/docs/wiki/Configuration:-Input.md @@ -103,6 +103,7 @@ input { } // disable-power-key-handling + // wake-monitors-on-input false // warp-mouse-to-focus // focus-follows-mouse max-scroll-amount="0%" // workspace-auto-back-and-forth @@ -314,6 +315,23 @@ input { } ``` +#### `wake-monitors-on-input` + +By default, any input (a key press, mouse movement, etc.) powers the monitors back on after the `power-off-monitors` action. +Set this to `false` to keep them off until the `power-on-monitors` action runs, for example from a bind or from `niri msg action power-on-monitors`. + +Binds keep working while the monitors are off, and input still reaches the focused window. + +```kdl +input { + wake-monitors-on-input false +} + +binds { + Mod+Ctrl+M { power-on-monitors; } +} +``` + #### `warp-mouse-to-focus` Makes the mouse warp to newly focused windows. diff --git a/niri-config/src/input.rs b/niri-config/src/input.rs index 0ac0821f..68f1e387 100644 --- a/niri-config/src/input.rs +++ b/niri-config/src/input.rs @@ -8,7 +8,7 @@ use crate::binds::Modifiers; use crate::utils::{Flag, MergeWith, Percent}; use crate::FloatOrInt; -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, PartialEq)] pub struct Input { pub keyboard: Keyboard, pub touchpad: Touchpad, @@ -18,6 +18,7 @@ pub struct Input { pub tablet: Tablet, pub touch: Touch, pub disable_power_key_handling: bool, + pub wake_monitors_on_input: bool, pub warp_mouse_to_focus: Option, pub focus_follows_mouse: Option, pub workspace_auto_back_and_forth: bool, @@ -25,6 +26,27 @@ pub struct Input { pub mod_key_nested: Option, } +impl Default for Input { + fn default() -> Self { + Self { + keyboard: Default::default(), + touchpad: Default::default(), + mouse: Default::default(), + trackpoint: Default::default(), + trackball: Default::default(), + tablet: Default::default(), + touch: Default::default(), + disable_power_key_handling: false, + wake_monitors_on_input: true, + warp_mouse_to_focus: None, + focus_follows_mouse: None, + workspace_auto_back_and_forth: false, + mod_key: None, + mod_key_nested: None, + } + } +} + #[derive(knuffel::Decode, Debug, Default, PartialEq)] pub struct InputPart { #[knuffel(child)] @@ -43,6 +65,8 @@ pub struct InputPart { pub touch: Option, #[knuffel(child)] pub disable_power_key_handling: Option, + #[knuffel(child, unwrap(argument))] + pub wake_monitors_on_input: Option, #[knuffel(child)] pub warp_mouse_to_focus: Option, #[knuffel(child)] @@ -64,6 +88,10 @@ impl MergeWith for Input { workspace_auto_back_and_forth, ); + if let Some(x) = part.wake_monitors_on_input { + self.wake_monitors_on_input = x; + } + merge_clone!( (self, part), touchpad, diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 378da877..b781f746 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -1188,6 +1188,7 @@ mod tests { } disable-power-key-handling + wake-monitors-on-input false warp-mouse-to-focus focus-follows-mouse @@ -1600,6 +1601,7 @@ mod tests { ), }, disable_power_key_handling: true, + wake_monitors_on_input: false, warp_mouse_to_focus: Some( WarpMouseToFocus { mode: None, diff --git a/src/input/mod.rs b/src/input/mod.rs index c3163326..71b87dc5 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -163,8 +163,11 @@ impl State { self.niri.notify_activity(); } } else { - // Power on monitors if they were off. - if should_activate_monitors(&event) { + // Power on monitors if they were off, unless the config leaves that to the + // power-on-monitors action. + if self.niri.config.borrow().input.wake_monitors_on_input + && should_activate_monitors(&event) + { self.niri.activate_monitors(&mut self.backend); // Notify the idle-notifier of activity only if we're also powering on the