feat: implement modal keybindings for layout and master pane control
Add XMonad.Hooks.Modal to separate layout switching and master pane manipulation into distinct modal namespaces. This resolves keybinding conflicts and creates a more organized interaction model. Changes: - Layout mode (M-a l): one-shot layout selection (d/m/f) - Master mode (M-a m): persistent pane adjustments with arrow keys - Restore ppExtras with logMode to display active mode in xmobar - Remove conflicting Home/End/PageUp/PageDown bindings from master pane - Simplify navigation by moving screen focus back to Home/End
This commit is contained in:
parent
9ce0ee6dcc
commit
064256e4ed
1 changed files with 33 additions and 15 deletions
|
|
@ -6,6 +6,7 @@ import XMonad.Actions.RotSlaves
|
|||
import XMonad.Hooks.DynamicLog
|
||||
import XMonad.Hooks.EwmhDesktops
|
||||
import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Hooks.Modal
|
||||
import XMonad.Hooks.StatusBar
|
||||
import XMonad.Layout.NoBorders
|
||||
import XMonad.Layout.Renamed
|
||||
|
|
@ -30,6 +31,7 @@ main = xmonad
|
|||
. ewmhFullscreen
|
||||
. ewmh
|
||||
. withSB myXmobar
|
||||
. modal [layoutMode, masterMode]
|
||||
$ myConfig
|
||||
|
||||
myConfig = def
|
||||
|
|
@ -74,10 +76,9 @@ myKeymap =
|
|||
, ("M-a t", spawn myFileManager)
|
||||
, ("M-a s", spawn myScrot )
|
||||
|
||||
-- toggling layouts
|
||||
, ("M-a d", sendMessage $ JumpToLayout "dynamic tiling")
|
||||
, ("M-a m", sendMessage $ JumpToLayout "maximised" )
|
||||
, ("M-a f", sendMessage $ JumpToLayout "fullscreen" )
|
||||
-- modal modes
|
||||
, ("M-a l", setMode "layout")
|
||||
, ("M-a m", setMode "master")
|
||||
|
||||
-- quit window
|
||||
, ("M-a q", kill)
|
||||
|
|
@ -96,12 +97,12 @@ myKeymap =
|
|||
, ("M-<Right>", moveTo Next hiddenWS)
|
||||
|
||||
-- window rotation
|
||||
, ("M-S-<Up>", rotAllUp)
|
||||
, ("M-S-<Down>", rotAllDown)
|
||||
, ("M-<Page_Up>" , rotAllUp)
|
||||
, ("M-<Page_Down>", rotAllDown)
|
||||
|
||||
-- focus screens
|
||||
, ("M-S-<Left>", prevScreen)
|
||||
, ("M-S-<Right>", nextScreen)
|
||||
, ("M-<Home>", prevScreen)
|
||||
, ("M-<End>" , nextScreen)
|
||||
|
||||
-- switch workspaces
|
||||
, ("M-1", windows $ W.greedyView "code" )
|
||||
|
|
@ -117,12 +118,6 @@ myKeymap =
|
|||
, ("M-S-4", windows $ W.shift "games")
|
||||
, ("M-S-5", windows $ W.shift "misc" )
|
||||
|
||||
-- master pane manipulation
|
||||
, ("M-<Home>", sendMessage Shrink) -- shrink master pane width
|
||||
, ("M-<End>", sendMessage Expand) -- expand master pane width
|
||||
, ("M-<Page_Up>", sendMessage (IncMasterN 1)) -- more windows in master
|
||||
, ("M-<Page_Down>", sendMessage (IncMasterN (-1))) -- fewer windows in master
|
||||
|
||||
-- master window operations
|
||||
, ("M-<Delete>", windows W.focusMaster)
|
||||
, ("M-S-<Delete>", windows W.swapMaster )
|
||||
|
|
@ -141,6 +136,26 @@ myKeymap =
|
|||
]
|
||||
|
||||
|
||||
--
|
||||
-- Modal Modes
|
||||
--
|
||||
|
||||
layoutMode :: Mode
|
||||
layoutMode = mode "layout" $ mkKeysEz
|
||||
[ ("d", sendMessage (JumpToLayout "dynamic tiling"))
|
||||
, ("m", sendMessage (JumpToLayout "maximised" ))
|
||||
, ("f", sendMessage (JumpToLayout "fullscreen" ))
|
||||
]
|
||||
|
||||
masterMode :: Mode
|
||||
masterMode = modeWithExit "master" $ mkKeysEz
|
||||
[ ("<Left>", sendMessage Shrink)
|
||||
, ("<Right>", sendMessage Expand)
|
||||
, ("<Up>", sendMessage (IncMasterN 1))
|
||||
, ("<Down>", sendMessage (IncMasterN (-1)))
|
||||
]
|
||||
|
||||
|
||||
--
|
||||
-- Layouts
|
||||
--
|
||||
|
|
@ -175,8 +190,11 @@ myXmobarPP = def
|
|||
, ppHiddenNoWindows = grey0 . wrap " " ""
|
||||
, ppUrgent = red . wrap " " ""
|
||||
, ppLayout = aqua . wrap (grey0 " <fn=1>[</fn> ") (grey0 " <fn=1>]</fn> ")
|
||||
, ppOrder = \[ws, l, _] -> [ws, l]
|
||||
, ppOrder = \case { [ws, l, title, mode] -> [ws, l, mode, title]; xs -> xs }
|
||||
, ppExtras = [lMode]
|
||||
}
|
||||
where
|
||||
lMode = xmobarColorL "#d8a657" "#282828" . fixedWidthL AlignCenter "-" 4 $ logMode
|
||||
|
||||
|
||||
--
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue