Advertisement
Haron_Prime

xmonad.hs

Mar 7th, 2017
187
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. -- Keybindings
  61. myKeys conf@(XConfig     {XMonad.modMask = modm})    =    M.fromList $
  62.     [ ((mod1Mask,                         0xff61),        spawn         "scrot  -s -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'")
  63.     , ((0,                                0xff61),        spawn         "scrot  -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'"   )
  64.     , ((0,                            0x1008ff13),        spawn         "amixer -q set Master       2dB+")
  65.     , ((0,                            0x1008ff11),        spawn         "amixer -q set Master       2dB-")
  66.     , ((0,                            0x1008ff12),        spawn         "amixer -q set Master toggleMute")
  67.     , ((modm,                               xK_a),        spawn         "urxvt  -e               ncmpcpp")
  68.     , ((modm         .|. shiftMask,         xK_b),        spawn         "urxvt  -e vim       ~/.xmobarrc")
  69.     , ((modm         .|. shiftMask,         xK_e),        spawn         "eject                  /dev/sr0")
  70.     , ((modm,                               xK_e),        spawn         "thunderbird"        )
  71.     , ((modm,                               xK_f),        spawn         "pcmanfm"            )
  72.     , ((modm,                               xK_p),        spawn         "dmenu_run"          )
  73.     , ((modm         .|. shiftMask,         xK_p),        spawn         "gmrun"              )
  74.     , ((modm,                               xK_q),        spawn         "xmonad --recompile && xmonad --restart && killall xmobar && xmobar")
  75.     , ((modm,                               xK_r),        spawn         "urxvt  -e ranger"   )
  76.     , ((modm,                               xK_s),        spawn         "subl"               )
  77.     , ((modm,                               xK_v),        spawn         "viewnior"           )
  78.     , ((modm,                               xK_w),        spawn         "vivaldi-stable"     )
  79.     , ((modm         .|. shiftMask,         xK_x),        spawn         "urxvt  -e vim ~/.xmonad/xmonad.hs")
  80.    
  81.  
  82.     , ((modm         .|. shiftMask,         xK_c),        kill)
  83.     , ((modm,                               xK_d),        sendMessage   Expand     )
  84.     , ((modm,                               xK_g),        sendMessage   Shrink     )
  85.     , ((modm,                               xK_j),        windows       W.focusDown)
  86.     , ((modm         .|. shiftMask,         xK_j),        windows       W.swapDown )
  87.     , ((modm,                               xK_k),        windows       W.focusUp  )
  88.     , ((modm         .|. shiftMask,         xK_k),        windows       W.swapUp   )
  89.     , ((modm,                               xK_m),        windows       W.focusMaster)
  90.     , ((modm,                               xK_n),                      refresh)
  91.     , ((modm         .|. shiftMask,         xK_q),        io            (exitWith ExitSuccess))
  92.     , ((modm         .|. shiftMask,         xK_t),        withFocused   $ windows . W.sink)
  93.     , ((modm,                               xK_t),        spawn         $ XMonad.terminal conf)
  94.     , ((modm,                             xK_Tab),        windows       W.focusDown)
  95.     , ((modm,                           xK_space),        sendMessage   NextLayout)
  96.     , ((modm         .|. shiftMask,     xK_space),        setLayout     $ XMonad.layoutHook conf)
  97.     , ((modm,                           xK_comma),        sendMessage   (IncMasterN 1))
  98.     , ((modm,                          xK_Return),        windows       W.swapMaster)
  99.     , ((modm,                          xK_period),        sendMessage   (IncMasterN (-1)))
  100.     ]
  101.  
  102.     ++
  103.     [ ((m            .|.                 modm, k),        windows       $ f i)
  104.     | (i, k) <- zip (XMonad.workspaces      conf)         [xK_1 .. xK_9]
  105.     , (f, m) <- [(W.greedyView,                0)
  106.     , (W.shift,                        shiftMask)         ]]
  107.     ++
  108.     [((m             .|.               modm, key),        screenWorkspace sc >>= flip whenJust (windows . f))
  109.     | (key, sc) <- zip [xK_u, xK_o, xK_i]   [0..]
  110.     , (f, m) <- [(W.view,                      0),
  111.       (W.shift,                      shiftMask)]]
  112.  
  113. -- Workspaces
  114. myWorkspaces          :: [String]
  115. myWorkspaces          =  [ "W", "M", "F", "T", "C"]
  116.  
  117. -- My Layouts
  118. myLayout              =  gaps [(U,16),(L,0),(R,0)]
  119.                       $  spacing 0
  120.                       $  lessBorders OnlyFloat
  121.                       $  tiled ||| Mirror tiled ||| Full
  122.    
  123.     where
  124.     tiled             =  Tall nmaster delta ratio
  125.     nmaster           =  1
  126.     ratio             =  1/2
  127.     delta             =  3/100
  128.  
  129. -- Window rules
  130. myManageHook          =  composeAll
  131.     [ isFullscreen                  --> doFloat
  132.     , className       =? "mpv"      --> doFullFloat
  133.     ]
  134.  
  135. -- MyBar
  136. myBar                 =  "xmobar"
  137.  
  138. -- Event handling
  139. myEventHook           =  ewmhDesktopsEventHook
  140.  
  141. -- Status bars and logging
  142. myLogHook             =  return ()
  143.  
  144. -- Startup hook
  145. myStartupHook         =  return ()
  146.  
  147. main = do
  148.        xmonad =<< xmobar myConfig
  149. myConfig = ewmh $ def {
  150.    terminal           =  myTerminal,
  151.    focusFollowsMouse  =  myFocusFollowsMouse,
  152.    clickJustFocuses   =  myClickJustFocuses,
  153.    borderWidth        =  myBorderWidth,
  154.    modMask            =  myModMask,
  155.    workspaces         =  myWorkspaces,
  156.    normalBorderColor  =  myNormalBorderColor,
  157.    focusedBorderColor =  myFocusedBorderColor,
  158.    keys               =  myKeys,
  159.    layoutHook         =  myLayout,
  160.    manageHook         =  myManageHook <+> fullscreenEventHook,
  161.    handleEventHook    =  myEventHook,
  162.    logHook            =  myLogHook,
  163.    startupHook        =  myStartupHook
  164.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement