Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 767317f0 rédigé par salixor's avatar salixor
Parcourir les fichiers

Spawn a program when pressing an Fn key

parent 54e91347
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
use smithay::{
backend::input::{
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent,
KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent,
},
input::{
keyboard::FilterResult,
......@@ -13,6 +13,8 @@ use smithay::{
use crate::state::Smallvil;
const PROGRAM_TO_SPAWN: &str = "konsole";
impl Smallvil {
pub fn process_input_event<I: InputBackend>(&mut self, event: InputEvent<I>) {
match event {
......@@ -26,7 +28,17 @@ impl Smallvil {
event.state(),
serial,
time,
|_, _, _| FilterResult::Forward,
|_, _, handle| {
let state = event.state();
let keysym = handle.modified_sym();
if state == KeyState::Pressed && keysym.is_function_key() {
std::process::Command::new(PROGRAM_TO_SPAWN).spawn().ok();
return FilterResult::Intercept(());
}
FilterResult::Forward
},
);
}
InputEvent::PointerMotion { .. } => {}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter