Skip to content

Commit

Permalink
added power-on-monitors (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
brainlessbitch authored Oct 9, 2024
1 parent 03c6039 commit e247231
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions niri-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ pub enum Action {
ChangeVt(i32),
Suspend,
PowerOffMonitors,
PowerOnMonitors,
ToggleDebugTint,
DebugToggleOpaqueRegions,
DebugToggleDamage,
Expand Down Expand Up @@ -1182,6 +1183,7 @@ impl From<niri_ipc::Action> 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,
Expand Down
2 changes: 2 additions & 0 deletions niri-ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -2582,14 +2585,19 @@ fn allowed_when_locked(action: &Action) -> bool {
| Action::ChangeVt(_)
| Action::Suspend
| Action::PowerOffMonitors
| Action::PowerOnMonitors
| Action::SwitchLayout(_)
)
}

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
)
}

Expand Down

0 comments on commit e247231

Please sign in to comment.