Add new shortcut to center the currently focused window

This commit is contained in:
EEva (JPotier) 2021-01-06 10:51:39 +02:00
parent b04bc2b679
commit c2aca9ce98
2 changed files with 16 additions and 1 deletions

View file

@ -24,6 +24,7 @@ import qualified Nord as N
import qualified Scratchpad as R
import qualified XMonad.StackSet as W
-- Custom (in libs)
import Password (passPrompt)
@ -60,6 +61,7 @@ modify conf = conf
, ("M-p n", switchProjectPrompt promptConfig)
, ("M-p r", renameProjectPrompt promptConfig)
, ("M-p s", shellPrompt promptConfig)
, ("M-p c", withFocused centerWindow)
, ("M-d", passPrompt promptConfig)
-- Scratchpads
, ("M-p p", namedScratchpadAction R.pads "htop")
@ -72,6 +74,14 @@ viewProject id = do
Just p -> switchProject p
Nothing -> return ()
-- Borrowed from https://www.reddit.com/r/xmonad/comments/gzq316/how_can_i_centre_a_floating_window_without/fthtx29/
centerWindow :: Window -> X ()
centerWindow win = do
(_, W.RationalRect x y w h) <- floatLocation win
windows $ W.float win (W.RationalRect ((1 - w) / 2) ((1 - h) / 2) w h)
return ()
--, ( modm .|. xK_a ), withFocused centerWindow)
promptConfig = def
{ position = Bottom
, alwaysHighlight = True

View file

@ -36,7 +36,12 @@ projects =
, singleAppWithName "wire" "wire-desktop"
, singleTermAppWithName "email" "neomutt"
, Project { projectName = "admin"
, projectDirectory = "~/admin"
, projectDirectory = "~/admin/nixos-config"
, projectStartHook = Just $ do safeSpawn "vim" ["-g"]
safeSpawnProg term
}
, Project { projectName = "cdc-config"
, projectDirectory = "~/admin/cdc-config"
, projectStartHook = Just $ do safeSpawn "vim" ["-g"]
safeSpawnProg term
}