forge
Explore
Log in

Don't you dare go Hollow

input: add wake-monitors-on-input option

Browse files at this commit

567a1002737294103c8d67659e126165101fc3e6Ahmet Kaan GümüşParent: 9d8f4f8
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.mdmodified+18 -0
@@ -103,6 +103,7 @@ input {
103 }103 }
104 104
105 // disable-power-key-handling105 // disable-power-key-handling
106+ // wake-monitors-on-input false
106 // warp-mouse-to-focus107 // warp-mouse-to-focus
107 // focus-follows-mouse max-scroll-amount="0%"108 // focus-follows-mouse max-scroll-amount="0%"
108 // workspace-auto-back-and-forth109 // workspace-auto-back-and-forth
@@ -314,6 +315,23 @@ input {
314 }315 }
315 ```316 ```
316 317
318+#### `wake-monitors-on-input`
319+
320+By default, any input (a key press, mouse movement, etc.) powers the monitors back on after the `power-off-monitors` action.
321+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`.
322+
323+Binds keep working while the monitors are off, and input still reaches the focused window.
324+
325+```kdl
326+input {
327+ wake-monitors-on-input false
328+}
329+
330+binds {
331+ Mod+Ctrl+M { power-on-monitors; }
332+}
333+```
334+
317 #### `warp-mouse-to-focus`335 #### `warp-mouse-to-focus`
318 336
319 Makes the mouse warp to newly focused windows.337 Makes the mouse warp to newly focused windows.
niri-config/src/input.rsmodified+29 -1
@@ -8,7 +8,7 @@ use crate::binds::Modifiers;
8 use crate::utils::{Flag, MergeWith, Percent};8 use crate::utils::{Flag, MergeWith, Percent};
9 use crate::FloatOrInt;9 use crate::FloatOrInt;
10 10
11-#[derive(Debug, Default, PartialEq)]11+#[derive(Debug, PartialEq)]
12 pub struct Input {12 pub struct Input {
13 pub keyboard: Keyboard,13 pub keyboard: Keyboard,
14 pub touchpad: Touchpad,14 pub touchpad: Touchpad,
@@ -18,6 +18,7 @@ pub struct Input {
18 pub tablet: Tablet,18 pub tablet: Tablet,
19 pub touch: Touch,19 pub touch: Touch,
20 pub disable_power_key_handling: bool,20 pub disable_power_key_handling: bool,
21+ pub wake_monitors_on_input: bool,
21 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,22 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,
22 pub focus_follows_mouse: Option<FocusFollowsMouse>,23 pub focus_follows_mouse: Option<FocusFollowsMouse>,
23 pub workspace_auto_back_and_forth: bool,24 pub workspace_auto_back_and_forth: bool,
@@ -25,6 +26,27 @@ pub struct Input {
25 pub mod_key_nested: Option<ModKey>,26 pub mod_key_nested: Option<ModKey>,
26 }27 }
27 28
29+impl Default for Input {
30+ fn default() -> Self {
31+ Self {
32+ keyboard: Default::default(),
33+ touchpad: Default::default(),
34+ mouse: Default::default(),
35+ trackpoint: Default::default(),
36+ trackball: Default::default(),
37+ tablet: Default::default(),
38+ touch: Default::default(),
39+ disable_power_key_handling: false,
40+ wake_monitors_on_input: true,
41+ warp_mouse_to_focus: None,
42+ focus_follows_mouse: None,
43+ workspace_auto_back_and_forth: false,
44+ mod_key: None,
45+ mod_key_nested: None,
46+ }
47+ }
48+}
49+
28 #[derive(knuffel::Decode, Debug, Default, PartialEq)]50 #[derive(knuffel::Decode, Debug, Default, PartialEq)]
29 pub struct InputPart {51 pub struct InputPart {
30 #[knuffel(child)]52 #[knuffel(child)]
@@ -43,6 +65,8 @@ pub struct InputPart {
43 pub touch: Option<Touch>,65 pub touch: Option<Touch>,
44 #[knuffel(child)]66 #[knuffel(child)]
45 pub disable_power_key_handling: Option<Flag>,67 pub disable_power_key_handling: Option<Flag>,
68+ #[knuffel(child, unwrap(argument))]
69+ pub wake_monitors_on_input: Option<bool>,
46 #[knuffel(child)]70 #[knuffel(child)]
47 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,71 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,
48 #[knuffel(child)]72 #[knuffel(child)]
@@ -64,6 +88,10 @@ impl MergeWith<InputPart> for Input {
64 workspace_auto_back_and_forth,88 workspace_auto_back_and_forth,
65 );89 );
66 90
91+ if let Some(x) = part.wake_monitors_on_input {
92+ self.wake_monitors_on_input = x;
93+ }
94+
67 merge_clone!(95 merge_clone!(
68 (self, part),96 (self, part),
69 touchpad,97 touchpad,
niri-config/src/lib.rsmodified+2 -0
@@ -1188,6 +1188,7 @@ mod tests {
1188 }1188 }
1189 1189
1190 disable-power-key-handling1190 disable-power-key-handling
1191+ wake-monitors-on-input false
1191 1192
1192 warp-mouse-to-focus1193 warp-mouse-to-focus
1193 focus-follows-mouse1194 focus-follows-mouse
@@ -1600,6 +1601,7 @@ mod tests {
1600 ),1601 ),
1601 },1602 },
1602 disable_power_key_handling: true,1603 disable_power_key_handling: true,
1604+ wake_monitors_on_input: false,
1603 warp_mouse_to_focus: Some(1605 warp_mouse_to_focus: Some(
1604 WarpMouseToFocus {1606 WarpMouseToFocus {
1605 mode: None,1607 mode: None,
src/input/mod.rsmodified+5 -2
@@ -163,8 +163,11 @@ impl State {
163 self.niri.notify_activity();163 self.niri.notify_activity();
164 }164 }
165 } else {165 } else {
166- // Power on monitors if they were off.166+ // Power on monitors if they were off, unless the config leaves that to the
167- if should_activate_monitors(&event) {167+ // power-on-monitors action.
168+ if self.niri.config.borrow().input.wake_monitors_on_input
169+ && should_activate_monitors(&event)
170+ {
168 self.niri.activate_monitors(&mut self.backend);171 self.niri.activate_monitors(&mut self.backend);
169 172
170 // Notify the idle-notifier of activity only if we're also powering on the173 // Notify the idle-notifier of activity only if we're also powering on the