forge
Explore
Log in

Don't you dare go Hollow

input: Add bind for spawning alacritty

Browse files at this commit

b6a4570a432335289ed66cf865ca3a4b3e4a1d10Ivan MolodetskikhParent: 89349f2
src/input.rsmodified+11 -0
@@ -1,3 +1,5 @@
1+use std::process::Command;
2+
1 use smithay::backend::input::{3 use smithay::backend::input::{
2 AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,4 AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
3 KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,5 KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
@@ -12,6 +14,7 @@ use crate::niri::Niri;
12 enum InputAction {14 enum InputAction {
13 Quit,15 Quit,
14 ChangeVt(i32),16 ChangeVt(i32),
17+ SpawnTerminal,
15 }18 }
16 19
17 impl Niri {20 impl Niri {
@@ -45,6 +48,9 @@ impl Niri {
45 let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32;48 let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32;
46 FilterResult::Intercept(InputAction::ChangeVt(vt))49 FilterResult::Intercept(InputAction::ChangeVt(vt))
47 }50 }
51+ keysyms::KEY_t if mods.logo => {
52+ FilterResult::Intercept(InputAction::SpawnTerminal)
53+ }
48 _ => FilterResult::Forward,54 _ => FilterResult::Forward,
49 }55 }
50 } else {56 } else {
@@ -62,6 +68,11 @@ impl Niri {
62 InputAction::ChangeVt(vt) => {68 InputAction::ChangeVt(vt) => {
63 (*change_vt)(vt);69 (*change_vt)(vt);
64 }70 }
71+ InputAction::SpawnTerminal => {
72+ if let Err(err) = Command::new("alacritty").spawn() {
73+ warn!("error spawning alacritty: {err}");
74+ }
75+ }
65 }76 }
66 }77 }
67 }78 }