Skip to content

Commit

Permalink
Improvements to xmonad config
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Feb 21, 2024
1 parent ea34726 commit c53eb81
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions home-modules/xmonad/xmonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import XMonad.Hooks.ManageDocks
docks,
manageDocks,
)
import XMonad.Hooks.ManageHelpers (doFullFloat, isFullscreen)
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Layout.Fullscreen
Expand Down Expand Up @@ -73,6 +73,23 @@ infixr 0 ~>
(~>) :: a -> b -> (a, b)
(~>) = (,)

toggleFloat :: Window -> X ()
toggleFloat w =
windows
( \s ->
if M.member w (W.floating s)
then W.sink w s
else W.float w (W.RationalRect (1 / 3) (1 / 4) (1 / 2) (1 / 2)) s
)

toggleFullscreen :: X ()
toggleFullscreen =
withWindowSet $ \ws ->
withFocused $ \w -> do
let fullRect = W.RationalRect 0 0 1 1
let isFullFloat = w `M.lookup` W.floating ws == Just fullRect
windows $ if isFullFloat then W.sink w else W.float w fullRect

myKeys conf@(XConfig {XMonad.modMask = modm}) =
M.fromList $
-- launch a terminal
Expand Down Expand Up @@ -119,7 +136,7 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) =
(modm .|. shiftMask, xK_i) ~> sendMessage $ DecGap 10 R, -- decrement the right-hand gap

-- Toggle Full Screen
(modm .|. shiftMask, xK_f) ~> sendMessage (Toggle "Full"),
(modm .|. shiftMask, xK_f) ~> toggleFullscreen,
-- Rotate through the available layout algorithms
(modm, xK_n) ~> sendMessage NextLayout,
-- Reset the layouts on the current workspace to default
Expand All @@ -141,7 +158,7 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) =
-- Expand the master area
(modm .|. shiftMask, xK_l) ~> sendMessage Expand,
-- Push window back into tiling
(modm, xK_t) ~> withFocused $ windows . W.sink,
(modm, xK_t) ~> withFocused toggleFloat,
-- Increment the number of windows in the master area
(modm .|. shiftMask, xK_comma) ~> sendMessage (IncMasterN 1),
-- Deincrement the number of windows in the master area
Expand Down Expand Up @@ -180,9 +197,11 @@ myMouseBindings (XConfig {XMonad.modMask = modm}) =

myManageHook :: ManageHook
myManageHook =
composeAll
[ fmap not willFloat --> insertPosition Below Newer
]
fullscreenManageHook
<+> composeAll
[ fmap not willFloat --> insertPosition Below Newer,
isFullscreen --> doFullFloat
]

myLayout = avoidStruts (tiled ||| GridRatio (21 / 9) ||| spiral (21 / 9) ||| Mirror tiled)
where
Expand All @@ -198,11 +217,13 @@ myLayout = avoidStruts (tiled ||| GridRatio (21 / 9) ||| spiral (21 / 9) ||| Mir
outerGap = 0

myLayoutHook =
toggleLayouts
( smartBorders Full
)
$ gaps [(L, outerGap), (R, outerGap), (U, outerGap), (D, outerGap)]
$ spacingRaw False (Border 10 10 10 10) True (Border 10 10 10 10) True
spacingRaw
False
(Border 10 10 10 10)
True
(Border 10 10 10 10)
True
$ smartBorders
myLayout

toggleStrutsKey XConfig {XMonad.modMask = modm} = (modm, xK_b)
Expand Down

0 comments on commit c53eb81

Please sign in to comment.