added power-on-monitors (#723)

This commit is contained in:
Winter
2024-10-09 01:50:06 -07:00
committed by GitHub
parent 03c603918d
commit e24723125f
3 changed files with 13 additions and 1 deletions
+2
View File
@@ -1068,6 +1068,7 @@ pub enum Action {
ChangeVt(i32), ChangeVt(i32),
Suspend, Suspend,
PowerOffMonitors, PowerOffMonitors,
PowerOnMonitors,
ToggleDebugTint, ToggleDebugTint,
DebugToggleOpaqueRegions, DebugToggleOpaqueRegions,
DebugToggleDamage, DebugToggleDamage,
@@ -1182,6 +1183,7 @@ impl From<niri_ipc::Action> for Action {
match value { match value {
niri_ipc::Action::Quit { skip_confirmation } => Self::Quit(skip_confirmation), niri_ipc::Action::Quit { skip_confirmation } => Self::Quit(skip_confirmation),
niri_ipc::Action::PowerOffMonitors {} => Self::PowerOffMonitors, niri_ipc::Action::PowerOffMonitors {} => Self::PowerOffMonitors,
niri_ipc::Action::PowerOnMonitors {} => Self::PowerOnMonitors,
niri_ipc::Action::Spawn { command } => Self::Spawn(command), niri_ipc::Action::Spawn { command } => Self::Spawn(command),
niri_ipc::Action::DoScreenTransition { delay_ms } => Self::DoScreenTransition(delay_ms), niri_ipc::Action::DoScreenTransition { delay_ms } => Self::DoScreenTransition(delay_ms),
niri_ipc::Action::Screenshot {} => Self::Screenshot, niri_ipc::Action::Screenshot {} => Self::Screenshot,
+2
View File
@@ -132,6 +132,8 @@ pub enum Action {
}, },
/// Power off all monitors via DPMS. /// Power off all monitors via DPMS.
PowerOffMonitors {}, PowerOffMonitors {},
/// Power on all monitors via DPMS.
PowerOnMonitors {},
/// Spawn a command. /// Spawn a command.
Spawn { Spawn {
/// Command to spawn. /// Command to spawn.
+9 -1
View File
@@ -479,6 +479,9 @@ impl State {
Action::PowerOffMonitors => { Action::PowerOffMonitors => {
self.niri.deactivate_monitors(&mut self.backend); self.niri.deactivate_monitors(&mut self.backend);
} }
Action::PowerOnMonitors => {
self.niri.activate_monitors(&mut self.backend);
}
Action::ToggleDebugTint => { Action::ToggleDebugTint => {
self.backend.toggle_debug_tint(); self.backend.toggle_debug_tint();
self.niri.queue_redraw_all(); self.niri.queue_redraw_all();
@@ -2582,6 +2585,7 @@ fn allowed_when_locked(action: &Action) -> bool {
| Action::ChangeVt(_) | Action::ChangeVt(_)
| Action::Suspend | Action::Suspend
| Action::PowerOffMonitors | Action::PowerOffMonitors
| Action::PowerOnMonitors
| Action::SwitchLayout(_) | Action::SwitchLayout(_)
) )
} }
@@ -2589,7 +2593,11 @@ fn allowed_when_locked(action: &Action) -> bool {
fn allowed_during_screenshot(action: &Action) -> bool { fn allowed_during_screenshot(action: &Action) -> bool {
matches!( matches!(
action, action,
Action::Quit(_) | Action::ChangeVt(_) | Action::Suspend | Action::PowerOffMonitors Action::Quit(_)
| Action::ChangeVt(_)
| Action::Suspend
| Action::PowerOffMonitors
| Action::PowerOnMonitors
) )
} }