Advertisement
Guest User

xmonad.hs

a guest
May 2nd, 2021
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. import XMonad hiding ( (|||) )
  2.  
  3. import XMonad.Hooks.EwmhDesktops
  4. import XMonad.Hooks.DynamicLog
  5. import XMonad.Hooks.StatusBar
  6. import XMonad.Actions.CycleWS
  7. import XMonad.Util.Ungrab
  8. import XMonad.Util.EZConfig
  9.  
  10. -- Layout
  11. import XMonad.Layout.IndependentScreens
  12. import XMonad.Layout.LayoutCombinators
  13. import XMonad.Layout (Tall)
  14.  
  15. import Data.Monoid (mempty)
  16. import System.Exit
  17.  
  18. import qualified XMonad.StackSet as W
  19. import qualified Data.Map as M
  20.  
  21. myTerminal = "xfce4-terminal"
  22. myModMask = mod4Mask -- Super
  23. myBorderWidth = 3
  24.  
  25. -- Default workspaces
  26. -- Tagging: ["a", "b", "c"] ++ map show [4..9]
  27. --myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
  28.  
  29. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  30. -- workspaces
  31. [((m .|. modm, k), windows $ onCurrentScreen f i)
  32. | (i, k) <- zip (workspaces' conf) [xK_1 .. xK_9]
  33. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  34.  
  35. -- Mouse bindings
  36. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  37. [
  38. -- mod+button1 - set to floating mode, and move by dragging
  39. ((modm, button1), \w -> focus w >> mouseMoveWindow w
  40. >> windows W.shiftMaster)
  41. -- mod+button3 - set to floating mode, resize by dragging
  42. , ((modm, button3), \w -> focus w >> mouseResizeWindow w
  43. >> windows W.shiftMaster)
  44. ]
  45.  
  46. -- Layouts
  47. -- More info: https://wiki.haskell.org/Xmonad/Config_archive/Template_xmonad.hs_(0.9)
  48. myLayout = Tall 1 (3/100) (1/2) ||| Full ||| Full
  49.  
  50. -- Window rules
  51. myManageHook = composeAll
  52. [ className =? "Krita" --> doFloat
  53. , className =? "Nemo" --> doFloat
  54. , resource =? "desktop_window" --> doIgnore ]
  55.  
  56. -- Event handling
  57. --
  58. -- Defines a custom handler function for X Events. The function should
  59. -- return (All True) if the default handler is to be run afterwards. To
  60. -- combine event hooks use mappend or mconcat from Data.Monoid.
  61. myEventHook = mempty
  62.  
  63. -- Status bars and logging
  64. myLogHook = return ()
  65.  
  66. myStartupHook = return ()
  67.  
  68. myConfig = def
  69. { terminal = myTerminal
  70. , workspaces = withScreens 2 ["1", "2", "3", "4", "5", "6","7","8","9"]
  71. , modMask = myModMask
  72. , borderWidth = myBorderWidth
  73. -- key bindings
  74. , keys = myKeys
  75. , mouseBindings = myMouseBindings
  76. -- hooks and layouts
  77. , layoutHook = myLayout
  78. , handleEventHook = myEventHook
  79. , logHook = myLogHook
  80. , startupHook = myStartupHook
  81. }
  82. `additionalKeysP`
  83. [ ("M-<Return>", spawn "xfce4-terminal")
  84. , ("M-r", spawn "rofi -show drun -show-icons")
  85. , ("M-p", unGrab *> spawn "maim -s -u | xclip -selection clipboard -t image/png -i")
  86.  
  87. -- move focus to previous/next window
  88. , ("M-<Left>", windows W.focusUp)
  89. , ("M-<Right>", windows W.focusDown)
  90. , ("M-S-<Left>", sendMessage Shrink)
  91. , ("M-S-<Right>",sendMessage Expand)
  92.  
  93. -- swap windows
  94. , ("M-S-j", windows W.swapDown)
  95. , ("M-S-k", windows W.swapUp) -- swap with previous
  96.  
  97. -- switch screens/ws
  98. , ("M-,", prevScreen)
  99. , ("M-S-,", prevWS)
  100.  
  101. , ("M-.", nextScreen)
  102. , ("M-S-.", nextWS)
  103.  
  104. -- switch between layouts
  105. , ("M-t", withFocused $ windows . W.sink)
  106. , ("M-g", sendMessage $ JumpToLayout "Tall")
  107. , ("M-f", sendMessage $ JumpToLayout "Full")
  108.  
  109. , ("M-q", kill)
  110.  
  111. -- recompile/restart/quit xmonad
  112. , ("M-S-c", spawn "xmonad --recompile")
  113. , ("M-S-r", spawn "xmonad --restart")
  114. , ("M-S-q", io (exitWith ExitSuccess)) -- quit
  115. ]
  116.  
  117. myXmobarPP :: PP
  118. myXmobarPP = def
  119. { ppSep = " "
  120. , ppTitle = wrap (white "[") (white "]") . ppWindow
  121. , ppTitleSanitize = xmobarStrip
  122. , ppCurrent = wrap (blue "[") (blue "]") . ppWindow
  123. , ppHidden = white . wrap " " " "
  124. , ppHiddenNoWindows = lowWhite . wrap " " " "
  125. , ppUrgent = red
  126. }
  127. where
  128. ppWindow :: String -> String
  129. ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
  130.  
  131. white = xmobarColor "#ffffff" ""
  132. lowWhite = xmobarColor "#fbfbfb" ""
  133. blue = xmobarColor "#0000ff" ""
  134. red = xmobarColor "#ff0000" ""
  135.  
  136. main = xmonad
  137. . ewmh
  138. . ewmhFullscreen
  139. $ withEasySB (statusBarProp "xmobar" (pure myXmobarPP))
  140. defToggleStrutsKey
  141. myConfig
  142. -- where
  143. -- nbars = 1
  144. --hs = statusBarPropTo ("_XMONAD_LOG_" ++ show nbars) ("xmobar -x " ++ show nbars ++ " ~/.xmobarrc" ++ show nbars) (pure myXmobarPP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement