From cf51fa2e89b92754fda0664e57ba647491eac610 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 31 Jan 2024 12:11:44 -0700 Subject: Add limited ability to bind directly to keycodes. Binding to keycodes is good for nonmnemonic key bindings -- where the choice of key is due to its position on the keyboard rather than the character associated with it. Right now only window bindings and subbindings can use keycode bindings. Root bindings can still only be keysyms and buttons. I've been using this feature to map some movement keys to Hyper. This emulates the function key on my M770 keyboard where fn+ijkl are used as arrow keys. I use the tab key as my hyper key. With xcape it can operate as a Tab key when release, or a modifier key when held down, which is awesome. --- src/Rahm/Desktop/Submap.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Rahm/Desktop/Submap.hs') diff --git a/src/Rahm/Desktop/Submap.hs b/src/Rahm/Desktop/Submap.hs index 246d85c..46508d7 100644 --- a/src/Rahm/Desktop/Submap.hs +++ b/src/Rahm/Desktop/Submap.hs @@ -68,7 +68,7 @@ import XMonad shiftMask, ungrabKeyboard, ungrabPointer, - (.|.), + (.|.), KeyCode, ) import qualified XMonad.Util.ExtensibleState as XS import XMonad.Util.Loggers (logSp) @@ -121,6 +121,7 @@ data ButtonOrKeyEvent | KeyPress { event_mask :: KeyMask, event_keysym :: KeySym, + event_keycode :: KeyCode, event_string :: String } @@ -149,9 +150,9 @@ nextButtonOrKeyEvent = do KeyEvent {ev_keycode = code, ev_state = m} -> do keysym <- keycodeToKeysym d code 0 (_, str) <- lookupString (asKeyEvent p) - return $ KeyPress m keysym str + return $ KeyPress m keysym code str case ret of - Just (KeyPress m sym str) | isModifierKey sym -> tryAgain + Just (KeyPress m sym _ str) | isModifierKey sym -> tryAgain x -> return x ) ) -- cgit