aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-03 07:31:44 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-03 07:31:44 +0400
commit14729f772bfc049cfe04d43b5a5ab7186c2bc021 (patch)
tree1529d773c747a8f865ad87f28c9df50cf908275c /src/input.rs
parent2c1d2ce0d33401990734d07d5910def97dc82998 (diff)
downloadniri-14729f772bfc049cfe04d43b5a5ab7186c2bc021.tar.gz
niri-14729f772bfc049cfe04d43b5a5ab7186c2bc021.tar.bz2
niri-14729f772bfc049cfe04d43b5a5ab7186c2bc021.zip
Add suspend key handling
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/input.rs b/src/input.rs
index 05a7d0f1..7dc34b31 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -24,6 +24,7 @@ enum Action {
None,
Quit,
ChangeVt(i32),
+ Suspend,
Spawn(String),
Screenshot,
CloseWindow,
@@ -57,6 +58,7 @@ enum Action {
pub enum BackendAction {
None,
ChangeVt(i32),
+ Suspend,
Screenshot,
}
@@ -78,9 +80,15 @@ fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) -
use keysyms::*;
let modified = keysym.modified_sym();
- if matches!(modified, KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12) {
- let vt = (modified - KEY_XF86Switch_VT_1 + 1) as i32;
- return Action::ChangeVt(vt);
+
+ #[allow(non_upper_case_globals)] // wat
+ match modified {
+ modified @ KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12 => {
+ let vt = (modified - KEY_XF86Switch_VT_1 + 1) as i32;
+ return Action::ChangeVt(vt);
+ }
+ KEY_XF86PowerOff => return Action::Suspend,
+ _ => (),
}
let mod_down = match comp_mod {
@@ -182,6 +190,9 @@ impl Niri {
Action::ChangeVt(vt) => {
return BackendAction::ChangeVt(vt);
}
+ Action::Suspend => {
+ return BackendAction::Suspend;
+ }
Action::Spawn(command) => {
if let Err(err) = Command::new(command).spawn() {
warn!("error spawning alacritty: {err}");