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.DynamicLog
|
||||||
import XMonad.Hooks.EwmhDesktops
|
import XMonad.Hooks.EwmhDesktops
|
||||||
import XMonad.Hooks.ManageDocks
|
import XMonad.Hooks.ManageDocks
|
||||||
|
import XMonad.Hooks.Modal
|
||||||
import XMonad.Hooks.StatusBar
|
import XMonad.Hooks.StatusBar
|
||||||
import XMonad.Layout.NoBorders
|
import XMonad.Layout.NoBorders
|
||||||
import XMonad.Layout.Renamed
|
import XMonad.Layout.Renamed
|
||||||
|
|
@ -30,6 +31,7 @@ main = xmonad
|
||||||
. ewmhFullscreen
|
. ewmhFullscreen
|
||||||
. ewmh
|
. ewmh
|
||||||
. withSB myXmobar
|
. withSB myXmobar
|
||||||
|
. modal [layoutMode, masterMode]
|
||||||
$ myConfig
|
$ myConfig
|
||||||
|
|
||||||
myConfig = def
|
myConfig = def
|
||||||
|
|
@ -74,10 +76,9 @@ myKeymap =
|
||||||
, ("M-a t", spawn myFileManager)
|
, ("M-a t", spawn myFileManager)
|
||||||
, ("M-a s", spawn myScrot )
|
, ("M-a s", spawn myScrot )
|
||||||
|
|
||||||
-- toggling layouts
|
-- modal modes
|
||||||
, ("M-a d", sendMessage $ JumpToLayout "dynamic tiling")
|
, ("M-a l", setMode "layout")
|
||||||
, ("M-a m", sendMessage $ JumpToLayout "maximised" )
|
, ("M-a m", setMode "master")
|
||||||
, ("M-a f", sendMessage $ JumpToLayout "fullscreen" )
|
|
||||||
|
|
||||||
-- quit window
|
-- quit window
|
||||||
, ("M-a q", kill)
|
, ("M-a q", kill)
|
||||||
|
|
@ -96,12 +97,12 @@ myKeymap =
|
||||||
, ("M-<Right>", moveTo Next hiddenWS)
|
, ("M-<Right>", moveTo Next hiddenWS)
|
||||||
|
|
||||||
-- window rotation
|
-- window rotation
|
||||||
, ("M-S-<Up>", rotAllUp)
|
, ("M-<Page_Up>" , rotAllUp)
|
||||||
, ("M-S-<Down>", rotAllDown)
|
, ("M-<Page_Down>", rotAllDown)
|
||||||
|
|
||||||
-- focus screens
|
-- focus screens
|
||||||
, ("M-S-<Left>", prevScreen)
|
, ("M-<Home>", prevScreen)
|
||||||
, ("M-S-<Right>", nextScreen)
|
, ("M-<End>" , nextScreen)
|
||||||
|
|
||||||
-- switch workspaces
|
-- switch workspaces
|
||||||
, ("M-1", windows $ W.greedyView "code" )
|
, ("M-1", windows $ W.greedyView "code" )
|
||||||
|
|
@ -117,12 +118,6 @@ myKeymap =
|
||||||
, ("M-S-4", windows $ W.shift "games")
|
, ("M-S-4", windows $ W.shift "games")
|
||||||
, ("M-S-5", windows $ W.shift "misc" )
|
, ("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
|
-- master window operations
|
||||||
, ("M-<Delete>", windows W.focusMaster)
|
, ("M-<Delete>", windows W.focusMaster)
|
||||||
, ("M-S-<Delete>", windows W.swapMaster )
|
, ("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
|
-- Layouts
|
||||||
--
|
--
|
||||||
|
|
@ -175,8 +190,11 @@ myXmobarPP = def
|
||||||
, ppHiddenNoWindows = grey0 . wrap " " ""
|
, ppHiddenNoWindows = grey0 . wrap " " ""
|
||||||
, ppUrgent = red . wrap " " ""
|
, ppUrgent = red . wrap " " ""
|
||||||
, ppLayout = aqua . wrap (grey0 " <fn=1>[</fn> ") (grey0 " <fn=1>]</fn> ")
|
, 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