diff options
Diffstat (limited to 'src/Rahm/Desktop/Keys.hs')
| -rw-r--r-- | src/Rahm/Desktop/Keys.hs | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index 518977e..49f0ebf 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -46,6 +46,8 @@ import Rahm.Desktop.Common locationWorkspace, runMaybeT_, withBorderColor, + withBorderColorM, + Location(..), ) import Rahm.Desktop.DMenu (runDMenu) import Rahm.Desktop.History @@ -255,6 +257,17 @@ keyBindingToKeymap bindings config = Map.mapWithKey bindingToX (bindings config) mapping ) +mapWindows :: (Ord b) => (a -> b) -> W.StackSet i l a s sd -> W.StackSet i l b s sd +mapWindows fn (W.StackSet cur vis hidden float) = + W.StackSet + (mapScreen fn cur) + (map (mapScreen fn) vis) + (map (mapWorkspace fn) hidden) + (Map.mapKeys fn float) + where + mapScreen fn (W.Screen ws s sd) = W.Screen (mapWorkspace fn ws) s sd + mapWorkspace fn (W.Workspace t l s) = W.Workspace t l (fmap (fmap fn) s) + keymap :: XConfig l -> KeyBindings keymap = runKeys $ do config <- getConfig @@ -262,16 +275,27 @@ keymap = runKeys $ do let subkeys keysM = Submap (runKeys keysM config) repeatable keysM = Repeat (runKeys keysM config) - forM_ [("' ", xK_apostrophe), ("w ", xK_w)] $ \(buf, k) -> bind k $ do + bind xK_apostrophe $ justMod $ - doc "Jumps between marks." $ - pushPendingBuffer buf $ do + doc "Jump to a window" $ + pushPendingBuffer "' " $ do runMaybeT_ $ do l <- readNextLocationSet case l of (h : _) -> lift (focusLocation h) _ -> return () + bind xK_w $ do + justMod $ + doc "Swap windows with other windows" $ + pushPendingBuffer "w " $ do + runMaybeT_ $ do + l1 <- mapMaybe (\(Location _ w) -> w) <$> readNextLocationSet + withBorderColorM "#00ffff" l1 $ do + l2 <- mapMaybe (\(Location _ w) -> w) <$> readNextLocationSet + let rewriteMap = Map.fromList $ zip l1 l2 ++ zip l2 l1 + lift $ windows $ mapWindows (\w -> fromMaybe w (Map.lookup w rewriteMap)) + bind xK_BackSpace $ do -- The only raw keybinding. Meant to get a terminal to unbrick XMonad if -- something goes wrong with the keyboard layout and for first-time boots |