Advertisement
Haron_Prime

xmonad.hs

Mar 7th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- xmonad.hs: Configuration file for xmonad
  2.  
  3. -- Core
  4. import XMonad
  5. import qualified XMonad.StackSet as W
  6. import System.IO (hPutStrLn)
  7. import System.Exit
  8. import qualified Data.Map as M
  9. import XMonad.Util.EZConfig
  10.  
  11. -- Util
  12. import XMonad.Util.NamedScratchpad (NamedScratchpad(NS), namedScratchpadManageHook, namedScratchpadAction, customFloating)
  13. import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm, spawnPipe)
  14. import XMonad.Util.SpawnOnce
  15.  
  16. -- Hooks
  17. import XMonad.Hooks.EwmhDesktops
  18. import XMonad.Hooks.DynamicLog
  19. import XMonad.Hooks.ManageDocks
  20. import XMonad.Hooks.Place (placeHook, withGaps, smart)
  21. import XMonad.Hooks.InsertPosition
  22. import XMonad.Hooks.ManageHelpers
  23. import XMonad.Hooks.FloatNext (floatNextHook, toggleFloatNext, toggleFloatAllNew)
  24. import XMonad.Hooks.WorkspaceByPos
  25.  
  26. -- Actions
  27. import XMonad.Actions.Promote
  28. import XMonad.Actions.FloatSnap
  29. import XMonad.Actions.FloatKeys
  30.  
  31. -- Layouts
  32. import XMonad.Layout.Spacing (spacing)
  33. import XMonad.Layout.NoBorders
  34. import XMonad.Layout.Gaps
  35. import XMonad.Layout.ResizableTile
  36. import XMonad.Layout.OneBig
  37. import XMonad.Layout.AutoMaster
  38. import XMonad.Layout.Circle
  39. import XMonad.Layout.Grid
  40. import XMonad.Layout.Spiral
  41. import XMonad.Layout.NoBorders
  42. import XMonad.Layout.Mosaic
  43. import XMonad.Layout.TwoPane
  44. import XMonad.Layout.CenteredMaster
  45. import XMonad.Layout.Tabbed
  46. import XMonad.Layout.DragPane
  47. import XMonad.Layout.IM
  48.  
  49. -- Constants
  50. myModMask             =  mod4Mask
  51. myFocusFollowsMouse   =  False
  52. myClickJustFocuses    =  False
  53. myBorderWidth         =  2
  54. myTerminal            =  "urxvt"
  55. myNormalBorderColor   =  "#000000"
  56. myFocusedBorderColor  =  "#51c4d4"
  57. myBackgroundColor     =  "#fe8e38"
  58. myForegroundColor     =  "#c7c9cb"
  59.  
  60. -- Workspaces
  61. myWorkspaces          :: [String]
  62. myWorkspaces          =  [ "W", "M", "F", "T", "C"]
  63.  
  64. -- My Layouts
  65. myLayout              =  gaps [(U,16),(L,0),(R,0)]
  66.                       $  spacing 0
  67.                       $  lessBorders OnlyFloat
  68.                       $  tiled ||| Mirror tiled ||| Full
  69.    
  70.     where
  71.     tiled             =  Tall nmaster delta ratio
  72.     nmaster           =  1
  73.     ratio             =  1/2
  74.     delta             =  3/100
  75.  
  76. -- Window rules
  77. myManageHook          =  composeAll
  78.     [ isFullscreen                  --> doFloat
  79.     , className       =? "mpv"      --> doFullFloat
  80.     ]
  81.  
  82. -- MyBar
  83. myBar                 =  "xmobar"
  84.  
  85. -- Event handling
  86. myEventHook           =  ewmhDesktopsEventHook
  87.  
  88. -- Status bars and logging
  89. myLogHook             =  return ()
  90.  
  91. -- Startup hook
  92. myStartupHook         =  return ()
  93.  
  94. main do
  95.      xmonad =<< xmobar myConfig
  96. myConfig = ewmh $ def {
  97.    terminal           =  myTerminal,
  98.    focusFollowsMouse  =  myFocusFollowsMouse,
  99.    clickJustFocuses   =  myClickJustFocuses,
  100.    borderWidth        =  myBorderWidth,
  101.    modMask            =  myModMask,
  102.    workspaces         =  myWorkspaces,
  103.    normalBorderColor  =  myNormalBorderColor,
  104.    focusedBorderColor =  myFocusedBorderColor,
  105.    keys               =  myKeys,
  106.    layoutHook         =  myLayout,
  107.    manageHook         =  myManageHook <+> fullscreenEventHook,
  108.    handleEventHook    =  myEventHook,
  109.    logHook            =  myLogHook,
  110.    startupHook        =  myStartupHook
  111.   }
  112.  
  113. -- Keybindings
  114. myKeys conf@(XConfig     {XMonad.modMask = modm})    =    M.fromList $
  115.     [ ((mod1Mask,                         0xff61),        spawn         "scrot  -s -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'")
  116.     , ((0,                                0xff61),        spawn         "scrot  -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'"   )
  117.     , ((0,                            0x1008ff13),        spawn         "amixer -q set Master       2dB+")
  118.     , ((0,                            0x1008ff11),        spawn         "amixer -q set Master       2dB-")
  119.     , ((0,                            0x1008ff12),        spawn         "amixer -q set Master toggleMute")
  120.     , ((modm,                               xK_a),        spawn         "urxvt  -e               ncmpcpp")
  121.     , ((modm         .|. shiftMask,         xK_b),        spawn         "urxvt  -e vim       ~/.xmobarrc")
  122.     , ((modm         .|. shiftMask,         xK_e),        spawn         "eject                  /dev/sr0")
  123.     , ((modm,                               xK_e),        spawn         "thunderbird"        )
  124.     , ((modm,                               xK_f),        spawn         "pcmanfm"            )
  125.     , ((modm,                               xK_p),        spawn         "dmenu_run"          )
  126.     , ((modm         .|. shiftMask,         xK_p),        spawn         "gmrun"              )
  127.     , ((modm,                               xK_q),        spawn         "xmonad --recompile && xmonad --restart && killall xmobar && xmobar")
  128.     , ((modm,                               xK_r),        spawn         "urxvt  -e ranger"   )
  129.     , ((modm,                               xK_s),        spawn         "subl"               )
  130.     , ((modm,                               xK_v),        spawn         "viewnior"           )
  131.     , ((modm,                               xK_w),        spawn         "vivaldi-stable"     )
  132.     , ((modm         .|. shiftMask,         xK_x),        spawn         "urxvt  -e vim ~/.xmonad/xmonad.hs")
  133.    
  134.  
  135.     , ((modm         .|. shiftMask,         xK_c),        kill)
  136.     , ((modm,                               xK_d),        sendMessage   Expand     )
  137.     , ((modm,                               xK_g),        sendMessage   Shrink     )
  138.     , ((modm,                               xK_j),        windows       W.focusDown)
  139.     , ((modm         .|. shiftMask,         xK_j),        windows       W.swapDown )
  140.     , ((modm,                               xK_k),        windows       W.focusUp  )
  141.     , ((modm         .|. shiftMask,         xK_k),        windows       W.swapUp   )
  142.     , ((modm,                               xK_m),        windows       W.focusMaster)
  143.     , ((modm,                               xK_n),                      refresh)
  144.     , ((modm         .|. shiftMask,         xK_q),        io            (exitWith ExitSuccess))
  145.     , ((modm         .|. shiftMask,         xK_t),        withFocused   $ windows . W.sink)
  146.     , ((modm,                               xK_t),        spawn         $ XMonad.terminal conf)
  147.     , ((modm,                             xK_Tab),        windows       W.focusDown)
  148.     , ((modm,                           xK_space),        sendMessage   NextLayout)
  149.     , ((modm         .|. shiftMask,     xK_space),        setLayout     $ XMonad.layoutHook conf)
  150.     , ((modm,                           xK_comma),        sendMessage   (IncMasterN 1))
  151.     , ((modm,                          xK_Return),        windows       W.swapMaster)
  152.     , ((modm,                          xK_period),        sendMessage   (IncMasterN (-1)))
  153.     ]
  154.  
  155.     ++
  156.     [ ((m            .|.                 modm, k),        windows       $ f i)
  157.     | (i, k) <- zip (XMonad.workspaces      conf)         [xK_1 .. xK_9]
  158.     , (f, m) <- [(W.greedyView,                0)
  159.     , (W.shift,                        shiftMask)         ]]
  160.     ++
  161.     [((m             .|.               modm, key),        screenWorkspace sc >>= flip whenJust (windows . f))
  162.     | (key, sc) <- zip [xK_u, xK_o, xK_i]   [0..]
  163.     , (f, m) <- [(W.view,                      0),
  164.       (W.shift,                      shiftMask)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement