From e24723125f5ef91983735043fba893a940469686 Mon Sep 17 00:00:00 2001 From: Winter <102400503+brainlessbitch@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:50:06 -0700 Subject: [PATCH] added power-on-monitors (#723) --- niri-config/src/lib.rs | 2 ++ niri-ipc/src/lib.rs | 2 ++ src/input/mod.rs | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index bf08e1ba..17ed2440 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -1068,6 +1068,7 @@ pub enum Action { ChangeVt(i32), Suspend, PowerOffMonitors, + PowerOnMonitors, ToggleDebugTint, DebugToggleOpaqueRegions, DebugToggleDamage, @@ -1182,6 +1183,7 @@ impl From for Action { match value { niri_ipc::Action::Quit { skip_confirmation } => Self::Quit(skip_confirmation), niri_ipc::Action::PowerOffMonitors {} => Self::PowerOffMonitors, + niri_ipc::Action::PowerOnMonitors {} => Self::PowerOnMonitors, niri_ipc::Action::Spawn { command } => Self::Spawn(command), niri_ipc::Action::DoScreenTransition { delay_ms } => Self::DoScreenTransition(delay_ms), niri_ipc::Action::Screenshot {} => Self::Screenshot, diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs index 13365522..b7cfa192 100644 --- a/niri-ipc/src/lib.rs +++ b/niri-ipc/src/lib.rs @@ -132,6 +132,8 @@ pub enum Action { }, /// Power off all monitors via DPMS. PowerOffMonitors {}, + /// Power on all monitors via DPMS. + PowerOnMonitors {}, /// Spawn a command. Spawn { /// Command to spawn. diff --git a/src/input/mod.rs b/src/input/mod.rs index 7c43c896..70356253 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -479,6 +479,9 @@ impl State { Action::PowerOffMonitors => { self.niri.deactivate_monitors(&mut self.backend); } + Action::PowerOnMonitors => { + self.niri.activate_monitors(&mut self.backend); + } Action::ToggleDebugTint => { self.backend.toggle_debug_tint(); self.niri.queue_redraw_all(); @@ -2582,6 +2585,7 @@ fn allowed_when_locked(action: &Action) -> bool { | Action::ChangeVt(_) | Action::Suspend | Action::PowerOffMonitors + | Action::PowerOnMonitors | Action::SwitchLayout(_) ) } @@ -2589,7 +2593,11 @@ fn allowed_when_locked(action: &Action) -> bool { fn allowed_during_screenshot(action: &Action) -> bool { matches!( action, - Action::Quit(_) | Action::ChangeVt(_) | Action::Suspend | Action::PowerOffMonitors + Action::Quit(_) + | Action::ChangeVt(_) + | Action::Suspend + | Action::PowerOffMonitors + | Action::PowerOnMonitors ) }