all repos — xmonad-config @ ff8b92e597a292452831d2155fa452a8c89c38b6

personal xmonad config

xmonad.hs (view raw)

  1import qualified Data.Map as M
  2import System.Exit
  3
  4import XMonad
  5import qualified XMonad.StackSet as W
  6
  7import XMonad.Actions.GridSelect
  8import XMonad.Actions.WithAll
  9
 10import XMonad.Hooks.DynamicLog
 11import XMonad.Hooks.EwmhDesktops
 12import XMonad.Hooks.StatusBar
 13import XMonad.Hooks.StatusBar.PP
 14
 15import XMonad.Util.ClickableWorkspaces
 16import XMonad.Util.EZConfig
 17import XMonad.Util.NamedScratchpad
 18
 19import XMonad.Layout.Renamed
 20import XMonad.Layout.Spacing
 21import XMonad.Layout.ThreeColumns
 22
 23import LaNinpreConfig
 24
 25myKeys :: [(String, X ())]
 26myKeys = [ ("M-<Return>", spawn myTerminal)
 27         , ("M-w",        spawn myBrowser)
 28         , ("M-p",        spawn "dmenu_run")
 29         , ("<Print>",    spawn "scrot_cmd -f")
 30         , ("C-<Print>",  spawn "scrot_cmd -a")
 31         , ("M1-<Print>", spawn "scrot_cmd -w")
 32
 33         , ("M-s t",      namedScratchpadAction myScratchPads "terminal")
 34         , ("M-s c",      namedScratchpadAction myScratchPads "calculator")
 35         , ("M-s m",      namedScratchpadAction myScratchPads "mocp")
 36         , ("M-s v",      namedScratchpadAction myScratchPads "mpvfloat")
 37
 38         , ("M-g t",      goToSelected myGsConfig)
 39         , ("M-g b",      bringSelected myGsConfig)
 40         , ("M-g g",      mySpawnSelected myGsConfig myAppGrid)
 41
 42         , ("M-S-c",      kill)
 43         , ("M-<Space>",  sendMessage NextLayout)
 44         , ("M-h",        sendMessage Shrink)
 45         , ("M-l",        sendMessage Expand)
 46         , ("M-j",        windows W.focusDown)
 47         , ("M-k",        windows W.focusUp)
 48         , ("M-S-j",      windows W.swapDown)
 49         , ("M-S-k",      windows W.swapUp)
 50         , ("M-m",        windows W.focusMaster)
 51         , ("M-S-m",      windows W.swapMaster)
 52         , ("M-t",        withFocused $ windows . W.sink)
 53         , ("M-S-t",      sinkAll)
 54         , ("M-<Tab>",    toggleWindowSpacingEnabled >> toggleScreenSpacingEnabled)
 55
 56         , ("M-S-q",      io (exitWith ExitSuccess))
 57         , ("M-S-r",      spawn "xmonad --recompile && xmonad --restart")
 58         ]
 59         ++
 60         [("M-" ++ m ++ show k, windows $ f i)
 61             | (i, k) <- zip (myWorkspaces) [1..9]
 62             , (f, m) <- [(W.greedyView, ""), (W.shift, "S-")]
 63         ]
 64
 65myColorizer :: a -> Bool -> X (String, String)
 66myColorizer _ active = if active then return (col_bg_alt def, col_fg_alt def)
 67                                 else return (col_bg     def, col_fg     def)
 68
 69myGsConfig :: GSConfig a
 70myGsConfig = (buildDefaultGSConfig myColorizer)
 71           { gs_font = head myFonts
 72           , gs_bordercolor = col_bg_alt def
 73           }
 74
 75mySpawnSelected :: GSConfig String -> [(String, String)] -> X ()
 76mySpawnSelected conf lst = gridselect conf lst >>= flip whenJust spawn
 77
 78myXmobarPP :: PP
 79myXmobarPP = def
 80           { ppSep             = xmobarColor (col_bg_alt def) "" " | "
 81           , ppCurrent         = xmobarColor (col_fg_alt def) "" . sitelen
 82           , ppHidden          = xmobarColor (col_fg     def) "" . sitelen
 83           , ppHiddenNoWindows = xmobarColor (col_bg_alt def) "" . sitelen
 84           } where
 85               sitelen = xmobarFont 3
 86
 87mySB :: StatusBarConfig
 88mySB = statusBarProp "xmobar"
 89     $ clickablePP $ filterOutWsPP [scratchpadWorkspaceTag] myXmobarPP
 90
 91myLayout = tiled ||| threeCol ||| full
 92         where
 93            tiled    = renamed [Replace "lawa"]
 94                     $ spacingWithEdge space $ Tall nmaster delta ratio
 95            threeCol = renamed [Replace "supa"]
 96                     $ spacingWithEdge space $ ThreeColMid nmaster delta ratio
 97            full     = renamed [Replace "suli"] $ Full
 98            nmaster  = 1
 99            ratio    = 1/2
100            delta    = 3/100
101            space    = 4
102
103myConfig = def
104         { terminal           = myTerminal
105         , modMask            = myModMask
106         , layoutHook         = myLayout
107         , manageHook         = myManageHook <+> namedScratchpadManageHook myScratchPads
108         , workspaces         = myWorkspaces
109	     , borderWidth        = myBorderWidth
110         , keys               = const M.empty -- discard default keybindings
111         , normalBorderColor  = col_bg def
112         , focusedBorderColor = col_bg_alt def
113         } `additionalKeysP` myKeys
114
115main :: IO ()
116main = xmonad
117     . ewmhFullscreen
118     . ewmh
119     . withEasySB mySB defToggleStrutsKey
120     $ myConfig