From 7bd2db4851f244b2cd0c1a22130d241f5bb3dc42 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 5 Jul 2023 23:49:02 +0200 Subject: [PATCH] config: Allow KeyPatterns to be printed --- src/config/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 74d444f4..c5478238 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -8,7 +8,7 @@ use crate::{ wayland::protocols::output_configuration::OutputConfigurationState, }; use serde::{Deserialize, Serialize}; -use smithay::input::Seat; +use smithay::input::{keyboard::xkb::keysym_get_name, Seat}; pub use smithay::{ backend::input::KeyState, input::keyboard::{keysyms as KeySyms, Keysym, ModifiersState}, @@ -991,6 +991,26 @@ impl KeyPattern { } } +impl ToString for KeyPattern { + fn to_string(&self) -> String { + let mut result = String::new(); + if self.modifiers.logo { + result += "Super+"; + } + if self.modifiers.ctrl { + result += "Ctrl+"; + } + if self.modifiers.alt { + result += "Alt+"; + } + if self.modifiers.shift { + result += "Shift+"; + } + result += &keysym_get_name(self.key); + result + } +} + #[derive(Debug, Deserialize, Clone, PartialEq, Eq)] pub enum Action { Terminate,