forge
Explore
Log in

Don't you dare go Hollow

Add input.disable-monitor-wake option

Browse files at this commit

ae1ecbf6c5470fd183d0f54f90d3164e5b7858b0Ahmet Kaan GümüşParent: a8562a1
By default, any input powers monitors back on after power-off-monitors.
When this flag is set, monitors stay off until an explicit
power-on-monitors action, e.g. from a key bind. This matches behavior
available in other compositors (Hyprland's
mouse_move_enables_dpms/key_press_enables_dpms).
docs/wiki/Configuration:-Input.mdmodified+22 -0
@@ -314,6 +314,28 @@ input {
314 }314 }
315 ```315 ```
316 316
317+#### `disable-monitor-wake`
318+
319+<sup>Since: next release</sup>
320+
321+By default, when monitors are powered off (for example, with the `power-off-monitors` action), any input like moving the mouse or pressing a key powers them back on.
322+
323+Set this flag to keep the monitors off regardless of input.
324+Then, the only way to power them back on is the `power-on-monitors` action, for example bound to a key or invoked with `niri msg action power-on-monitors`.
325+
326+Keep in mind that other input keeps working normally while the monitors are off: keys will go to the focused window, and binds will trigger their actions.
327+
328+```kdl
329+input {
330+ disable-monitor-wake
331+}
332+
333+binds {
334+ Mod+Shift+P { power-off-monitors; }
335+ Mod+Shift+O { power-on-monitors; }
336+}
337+```
338+
317 #### `warp-mouse-to-focus`339 #### `warp-mouse-to-focus`
318 340
319 Makes the mouse warp to newly focused windows.341 Makes the mouse warp to newly focused windows.
niri-config/src/input.rsmodified+4 -0
@@ -24,6 +24,7 @@ pub struct Input {
24 pub tablet: Tablet,24 pub tablet: Tablet,
25 pub touch: Touch,25 pub touch: Touch,
26 pub disable_power_key_handling: bool,26 pub disable_power_key_handling: bool,
27+ pub disable_monitor_wake: bool,
27 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,28 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,
28 pub focus_follows_mouse: Option<FocusFollowsMouse>,29 pub focus_follows_mouse: Option<FocusFollowsMouse>,
29 pub workspace_auto_back_and_forth: bool,30 pub workspace_auto_back_and_forth: bool,
@@ -50,6 +51,8 @@ pub struct InputPart {
50 #[knuffel(child)]51 #[knuffel(child)]
51 pub disable_power_key_handling: Option<Flag>,52 pub disable_power_key_handling: Option<Flag>,
52 #[knuffel(child)]53 #[knuffel(child)]
54+ pub disable_monitor_wake: Option<Flag>,
55+ #[knuffel(child)]
53 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,56 pub warp_mouse_to_focus: Option<WarpMouseToFocus>,
54 #[knuffel(child)]57 #[knuffel(child)]
55 pub focus_follows_mouse: Option<FocusFollowsMouse>,58 pub focus_follows_mouse: Option<FocusFollowsMouse>,
@@ -67,6 +70,7 @@ impl MergeWith<InputPart> for Input {
67 (self, part),70 (self, part),
68 keyboard,71 keyboard,
69 disable_power_key_handling,72 disable_power_key_handling,
73+ disable_monitor_wake,
70 workspace_auto_back_and_forth,74 workspace_auto_back_and_forth,
71 );75 );
72 76
niri-config/src/lib.rsmodified+2 -0
@@ -1221,6 +1221,7 @@ mod tests {
1221 }1221 }
1222 1222
1223 disable-power-key-handling1223 disable-power-key-handling
1224+ disable-monitor-wake
1224 1225
1225 warp-mouse-to-focus1226 warp-mouse-to-focus
1226 focus-follows-mouse1227 focus-follows-mouse
@@ -1633,6 +1634,7 @@ mod tests {
1633 ),1634 ),
1634 },1635 },
1635 disable_power_key_handling: true,1636 disable_power_key_handling: true,
1637+ disable_monitor_wake: true,
1636 warp_mouse_to_focus: Some(1638 warp_mouse_to_focus: Some(
1637 WarpMouseToFocus {1639 WarpMouseToFocus {
1638 mode: None,1640 mode: None,
src/input/mod.rsmodified+3 -1
@@ -164,7 +164,9 @@ impl State {
164 }164 }
165 } else {165 } else {
166 // Power on monitors if they were off.166 // Power on monitors if they were off.
167- if should_activate_monitors(&event) {167+ if !self.niri.config.borrow().input.disable_monitor_wake
168+ && should_activate_monitors(&event)
169+ {
168 self.niri.activate_monitors(&mut self.backend);170 self.niri.activate_monitors(&mut self.backend);
169 171
170 // Notify the idle-notifier of activity only if we're also powering on the172 // Notify the idle-notifier of activity only if we're also powering on the