diff options
| author | Josh Rahm <rahm@google.com> | 2024-01-31 12:11:44 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2024-01-31 12:11:44 -0700 |
| commit | cf51fa2e89b92754fda0664e57ba647491eac610 (patch) | |
| tree | f2fced9c44046c989dea8776b2bd6ce8810feadd /src/Rahm/Desktop/Submap.hs | |
| parent | af1333c9a1963f14079b8cb1ff4157414428b674 (diff) | |
| download | rde-cf51fa2e89b92754fda0664e57ba647491eac610.tar.gz rde-cf51fa2e89b92754fda0664e57ba647491eac610.tar.bz2 rde-cf51fa2e89b92754fda0664e57ba647491eac610.zip | |
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.
Diffstat (limited to 'src/Rahm/Desktop/Submap.hs')
| -rw-r--r-- | src/Rahm/Desktop/Submap.hs | 7 |
1 files changed, 4 insertions, 3 deletions
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 ) ) |