Advertisement
Guest User

xmonad.hs

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