Add input.disable-monitor-wake option
Browse files at this commitae1ecbf6c5470fd183d0f54f90d3164e5b7858b0Parent: a8562a14 changed files +31 -1
- docs/wiki/Configuration:-Input.md +22 -0
- niri-config/src/input.rs +4 -0
- niri-config/src/lib.rs +2 -0
- src/input/mod.rs +3 -1
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 | 339 | #### `warp-mouse-to-focus` |
| 318 | 340 | |
| 319 | 341 | Makes the mouse warp to newly focused windows. |
niri-config/src/input.rsmodified+4 -0
| @@ -24,6 +24,7 @@ pub struct Input { | ||
| 24 | 24 | pub tablet: Tablet, |
| 25 | 25 | pub touch: Touch, |
| 26 | 26 | pub disable_power_key_handling: bool, |
| 27 | + pub disable_monitor_wake: bool, | |
| 27 | 28 | pub warp_mouse_to_focus: Option<WarpMouseToFocus>, |
| 28 | 29 | pub focus_follows_mouse: Option<FocusFollowsMouse>, |
| 29 | 30 | pub workspace_auto_back_and_forth: bool, |
| @@ -50,6 +51,8 @@ pub struct InputPart { | ||
| 50 | 51 | #[knuffel(child)] |
| 51 | 52 | pub disable_power_key_handling: Option<Flag>, |
| 52 | 53 | #[knuffel(child)] |
| 54 | + pub disable_monitor_wake: Option<Flag>, | |
| 55 | + #[knuffel(child)] | |
| 53 | 56 | pub warp_mouse_to_focus: Option<WarpMouseToFocus>, |
| 54 | 57 | #[knuffel(child)] |
| 55 | 58 | pub focus_follows_mouse: Option<FocusFollowsMouse>, |
| @@ -67,6 +70,7 @@ impl MergeWith<InputPart> for Input { | ||
| 67 | 70 | (self, part), |
| 68 | 71 | keyboard, |
| 69 | 72 | disable_power_key_handling, |
| 73 | + disable_monitor_wake, | |
| 70 | 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 | 1223 | disable-power-key-handling |
| 1224 | + disable-monitor-wake | |
| 1224 | 1225 | |
| 1225 | 1226 | warp-mouse-to-focus |
| 1226 | 1227 | focus-follows-mouse |
| @@ -1633,6 +1634,7 @@ mod tests { | ||
| 1633 | 1634 | ), |
| 1634 | 1635 | }, |
| 1635 | 1636 | disable_power_key_handling: true, |
| 1637 | + disable_monitor_wake: true, | |
| 1636 | 1638 | warp_mouse_to_focus: Some( |
| 1637 | 1639 | WarpMouseToFocus { |
| 1638 | 1640 | mode: None, |
src/input/mod.rsmodified+3 -1
| @@ -164,7 +164,9 @@ impl State { | ||
| 164 | 164 | } |
| 165 | 165 | } else { |
| 166 | 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 | 170 | self.niri.activate_monitors(&mut self.backend); |
| 169 | 171 | |
| 170 | 172 | // Notify the idle-notifier of activity only if we're also powering on the |