From c2aca9ce9846e79e06468a3e325c43d86f3be4f6 Mon Sep 17 00:00:00 2001 From: "EEva (JPotier)" Date: Wed, 6 Jan 2021 10:51:39 +0200 Subject: [PATCH] Add new shortcut to center the currently focused window --- lib/KeyBindings.hs | 10 ++++++++++ lib/Projects.hs | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/KeyBindings.hs b/lib/KeyBindings.hs index fa2ad75..df518a3 100644 --- a/lib/KeyBindings.hs +++ b/lib/KeyBindings.hs @@ -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 diff --git a/lib/Projects.hs b/lib/Projects.hs index a71fd1c..fe635ff 100644 --- a/lib/Projects.hs +++ b/lib/Projects.hs @@ -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 }