Advertisement
psyq

xmonad.hs

Jan 22nd, 2016
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Imports.
  2. import XMonad
  3. import XMonad.Operations
  4. import System.IO
  5. import System.Exit
  6. import XMonad.Util.Run
  7. import XMonad.Actions.CycleWS
  8. import XMonad.Hooks.ManageHelpers
  9. import XMonad.Hooks.UrgencyHook
  10. import XMonad.Hooks.DynamicLog
  11. import XMonad.Hooks.ManageDocks    -- dock/tray mgmt
  12. import Data.Monoid
  13. import qualified XMonad.StackSet as W
  14. import qualified Data.Map        as M
  15. import System.Exit
  16. import XMonad.Layout.Grid
  17. import XMonad.Layout.NoBorders
  18. import XMonad.Layout.Tabbed
  19. import XMonad.Layout.Fullscreen
  20. import XMonad.Layout.IndependentScreens
  21.  
  22. -- The main function.
  23. main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig
  24.  
  25. -- Command to launch the bar.
  26. myBar = "xmobar"
  27.  
  28. -- Custom PP, configure it as you like. It determines what is being written to the bar.
  29. myPP = xmobarPP { ppVisible = xmobarColor "bright red" "", ppCurrent = xmobarColor "#2E9AFE" "", ppTitle = xmobarColor "black" "", ppHiddenNoWindows = xmobarColor "#0404B4" "", ppLayout =
  30. xmobarColor
  31. "#790a0a" "", ppUrgent
  32.  = xmobarColor "#525252" "" . wrap "[" "]" }
  33.  
  34. -- Key binding to toggle the gap for the bar.
  35. toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
  36.  
  37. -- Main configuration, override the defaults to your liking.
  38. myConfig = defaultConfig { modMask= mod1Mask
  39.                          , terminal = "urxvt"
  40.                          , workspaces = withScreens 3 (myWorkspaces)
  41.                          , keys = myKeys
  42.                          , layoutHook = smartBorders $ myLayoutHook
  43.                          , focusedBorderColor = "#2E9AFE"
  44.                          , normalBorderColor = "#000000"
  45.                          , manageHook = myManageHook <+> manageHook defaultConfig
  46.                          , mouseBindings = myMouseBindings
  47.                          , borderWidth         = 0
  48.                          }
  49.  
  50. --myWorkspaces    = ["1:Web","2:term","3:irc","4:files","5:steam","6","7","8","9"]
  51. xmobarEscape = concatMap doubleLts
  52.   where doubleLts '<' = "<<"
  53.         doubleLts x    = [x]
  54. myWorkspaces            :: [String]
  55. myWorkspaces            = clickable . (map xmobarEscape) $ ["1:Web","2:term","3:irc","4:files","5:steam","VI","VII","VIII","IX"]
  56.                                                                              
  57.   where                                                                      
  58.          clickable l = [ "<action=xdotool key alt+" ++ show (n) ++ ">" ++ ws ++ "</action>" |
  59.                              (i,ws) <- zip [1..9] l,                                        
  60.                             let n = i ]
  61. myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  62.  
  63.     -- launch a terminal
  64.     [ ((mod1Mask,              xK_Return), spawn "urxvt")
  65.  
  66.     -- launch dmenu
  67.     , ((modMask,               xK_d     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  68.  
  69.     -- launch gmrun
  70.     , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")
  71.  
  72.     -- close focused window
  73.     , ((modMask .|. shiftMask, xK_q     ), kill)
  74.  
  75.      -- Rotate through the available layout algorithms
  76.     , ((modMask,               xK_space ), sendMessage NextLayout)
  77.  
  78.     --  Reset the layouts on the current workspace to default
  79.     , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  80.  
  81.     -- Resize viewed windows to the correct size
  82.     , ((modMask,               xK_n     ), refresh)
  83.  
  84.     -- Move focus to the next window
  85.     , ((modMask,               xK_Tab   ), windows W.focusDown)
  86.  
  87.     -- Move focus to the next window
  88.     , ((modMask,               xK_j     ), windows W.focusDown)
  89.  
  90.     -- Move focus to the previous window
  91.     , ((modMask,               xK_k     ), windows W.focusUp  )
  92.    
  93.     -- Volume Control
  94.     , ((modMask,               xK_F11   ), spawn "amixer set Master 5%-")
  95.     , ((modMask,               xK_F12   ), spawn "amixer set Master 5%+")
  96.    
  97.     -- Brightness Control
  98.     , ((modMask,               xK_F4    ), spawn "xbacklight -dec 10")
  99.     , ((modMask,               xK_F5    ), spawn "xbacklight -inc 10")
  100.  
  101.     -- Move focus to the master window
  102.     , ((modMask,               xK_m     ), windows W.focusMaster  )
  103.  
  104.     -- Swap the focused window and the master window
  105.     , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
  106.  
  107.     -- Swap the focused window with the next window
  108.     , ((modMask .|. shiftMask, xK_j     ), windows W.swapDown  )
  109.  
  110.     -- Swap the focused window with the previous window
  111.     , ((modMask .|. shiftMask, xK_k     ), windows W.swapUp    )
  112.  
  113.     -- Shrink the master area
  114.     , ((modMask,               xK_h     ), sendMessage Shrink)
  115.  
  116.     -- Expand the master area
  117.     , ((modMask,               xK_l     ), sendMessage Expand)
  118.  
  119.     -- Push window back into tiling
  120.     , ((modMask,               xK_t     ), withFocused $ windows . W.sink)
  121.  
  122.     -- Increment the number of windows in the master area
  123.     , ((modMask              , xK_comma ), sendMessage (IncMasterN 1))
  124.  
  125.     -- Deincrement the number of windows in the master area
  126.     , ((modMask              , xK_period), sendMessage (IncMasterN (-1)))
  127.  
  128.     -- Toggle the status bar gap
  129.     -- Use this binding with avoidStruts from Hooks.ManageDocks.
  130.     -- See also the statusBar function from Hooks.DynamicLog.
  131.     --
  132.     -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
  133.    
  134.     -- Lock screen
  135.     , ((modMask .|. shiftMask, xK_z     ), spawn "xlock")
  136.     -- Quit xmonad
  137.     , ((modMask .|. shiftMask, xK_c     ), io (exitWith ExitSuccess))
  138.  
  139.     -- Restart xmonad
  140.     , ((modMask              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  141.     ]
  142.     ++
  143.  
  144.     --
  145.     -- mod-[1..9], Switch to workspace N
  146.     --
  147.     -- mod-[1..9], Switch to workspace N
  148.     -- mod-shift-[1..9], Move client to workspace N
  149.     --
  150.     [((m .|. modMask, k), windows $ onCurrentScreen f i)
  151.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  152.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  153.     ++
  154.  
  155.     --
  156.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  157.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  158.     --
  159.     [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  160.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  161.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  162.  
  163. myManageHook = composeAll
  164.     [ className =? "stalonetray"    --> doIgnore
  165.       , className =? "Steam"        --> doFullFloat
  166.       , title =? "LIMBO"            --> doIgnore
  167.       , title =? "FEZ"              --> doIgnore
  168.       , title =? "NMRIH"            --> doFullFloat
  169.       , className =? "MPlayer"      --> doFullFloat
  170.       , manageDocks
  171.       , isFullscreen                --> (doF W.focusDown <+> doFullFloat)
  172.     ]
  173.  
  174. -- Mouse bindings
  175.  
  176. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  177.  
  178.     -- mod-button1, Set the window to floating mode and move by dragging
  179.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  180.                                        >> windows W.shiftMaster))
  181.  
  182.     -- mod-button2, Raise the window to the top of the stack
  183.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  184.  
  185.     -- mod-button3, Set the window to floating mode and resize by dragging
  186.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  187.                                        >> windows W.shiftMaster))
  188.  
  189.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  190.     ]
  191.  
  192. myLayoutHook = avoidStruts (
  193.         Grid ||| Mirror tiled |||noBorders (fullscreenFull Full) ||| noBorders simpleTabbed ||| tiled)
  194.         where
  195.     -- default tiling algorithm partitions the screen into two panes
  196.     tiled   = Tall nmaster delta ratio
  197.  
  198.     -- The default number of windows in the master pane
  199.     nmaster = 1
  200.  
  201.     -- Default proportion of screen occupied by master pane
  202.     ratio   = 1/2
  203.  
  204.     -- Percent of screen to increment by when resizing panes
  205.     delta   = 3/100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement