From 2ec6937f9935123fd23f915ceb05385113f143bb Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 30 Jan 2024 23:14:40 -0700 Subject: Add movement keybindings to Mod3. These keybindings give me the ability to use arrow keys and other movement keys without physical keys. This is helped by my keyboard script which maps Tab to Hyper when held down, so tab acts like a function key of sorts. --- src/Rahm/Desktop/Keys.hs | 63 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index 7bceeef..0bf3ba0 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -141,7 +141,7 @@ import Rahm.Desktop.XMobarLog.PendingBuffer pushAddPendingBuffer, pushPendingBuffer, ) -import System.Exit (exitSuccess, exitFailure) +import System.Exit (exitFailure, exitSuccess) import Text.Printf (printf) import XMonad as X import XMonad.Actions.CopyWindow as CopyWindow @@ -1192,6 +1192,10 @@ bindings = do ) in windows f >> escape +-- where +-- +-- permuteMods = map (foldl' (.|.) 0) . filterM (const [True, False]) + myMouseMoveWindow = D.mouseMoveWindowAndThen X.focus $ mconcat @@ -1230,6 +1234,63 @@ windowSpecificBindings config = do in tell =<< lift (b --> return (keymap config)) emitKey = flip sendKey w + configureIf (return True) $ do + -- The following are bindings that send keystrokes to the focused window. This + -- makes navigating with arrow keys and whatnot much easier. + forM_ (permuteMods [0, controlMask, shiftMask]) $ \mods -> do + bind xK_c $ + rawMask (mod3Mask .|. mods) $ + emitKey (mods, xK_Up) + + bind xK_t $ + rawMask (mod3Mask .|. mods) $ + emitKey (mods, xK_Down) + + bind xK_h $ + rawMask (mod3Mask .|. mods) $ + emitKey (mods, xK_Left) + + bind xK_n $ + rawMask (mod3Mask .|. mods) $ + emitKey (mods, xK_Right) + + forM_ [0, shiftMask] $ \m -> do + bind xK_braceleft $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. controlMask, xK_Up) + + bind xK_braceright $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. controlMask, xK_Down) + + bind xK_dollar $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. 0, xK_End) + + bind xK_at $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. 0, xK_Home) + + bind xK_w $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. shiftMask, xK_BackSpace) + + bind xK_b $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. controlMask, xK_Left) + + bind xK_e $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. controlMask, xK_Right) + + bind xK_u $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. controlMask, xK_Page_Up) + + bind xK_d $ + rawMask (m .|. mod3Mask) $ + emitKey (m .|. controlMask, xK_Page_Down) + configureIf (flip elem (browsers ++ spotify) <$> className) $ do bind xK_h $ do rawMask controlMask $ emitKey (0, xK_BackSpace) -- cgit