Advertisement
Creqz

xmonad.hs

Feb 11th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. import Data.Monoid
  3. import qualified Data.Map        as M
  4. import qualified XMonad.StackSet as W -- manageHook rules
  5. import System.Environment
  6. import System.Exit
  7. import System.IO                      -- hPutStrLn scope
  8. import XMonad
  9. import XMonad.Hooks.DynamicLog        -- status
  10. import XMonad.Hooks.ManageDocks       -- dock/tray
  11. import XMonad.Hooks.UrgencyHook       -- notifications
  12. import XMonad.Layout.Named            -- custom layout names
  13. import XMonad.Layout.NoBorders        -- smart borders on solo clients
  14. import XMonad.Util.Loggers            -- not needed?
  15. import XMonad.Util.Run(spawnPipe)     -- spawnPipe and hPutStrLn
  16.  
  17.  
  18. main = do
  19.         myBG      <- getEnv "BG"     -- $BG = $BLACK
  20.         myFG      <- getEnv "FG"     -- $FG
  21.         myBLACK   <- getEnv "BLACK"
  22.         myBLUE    <- getEnv "BLUE"
  23.         myCYAN    <- getEnv "CYAN"
  24.         myGREEN   <- getEnv "GREEN"
  25.         myMAGENTA <- getEnv "MAGENTA"
  26.         myRED     <- getEnv "RED"
  27.         myWHITE   <- getEnv "WHITE"
  28.         myYELLOW  <- getEnv "YELLOW"
  29.         status    <- spawnPipe "dzen2 -bg $BG -fg $FG -fn $FONT -w $WIDTH -ta 'l' "                                         --myDzenStatus  --  xmonad status on the left
  30.         conky     <- spawnPipe "conky -c ~/.xmonad/conkyrc | dzen2 -bg $BG -fg $FG -fn $FONT -ta 'r' -w $WIDTH -x $WIDTH "  --myDzenConky   --  conky stats on the right
  31.         xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig
  32.             { terminal           = "urxvt"
  33.             , focusFollowsMouse  = True
  34.             , borderWidth        = 2
  35.             , modMask            = mod1Mask
  36.             , workspaces         = ["1","2","3","4","5","6","7","8","9"]
  37.             , normalBorderColor  = myBG
  38.             , focusedBorderColor = myYELLOW
  39.             , keys               = myKeys
  40.             , mouseBindings      = myMouseBindings
  41.             , layoutHook         = myLayout
  42.             , manageHook         = myManageHook
  43.             , logHook            = dynamicLogWithPP dzenPP
  44.                 { ppOutput          = hPutStrLn status
  45.                 , ppCurrent         = dzenColor myBLACK myYELLOW . pad  -- dzenColor $FG $BG
  46.                 , ppHidden          = dzenColor myFG myBG . pad         -- other WS in use but not currently on either monitor
  47.                 , ppHiddenNoWindows = dzenColor myBG "" . pad           -- unused windows (1-9)
  48.                 , ppLayout          = dzenColor myRED ""
  49.                 , ppSep             = " "                               -- between "9" and layout/title
  50.                 , ppTitle           = dzenColor myFG "" . pad
  51.                 , ppUrgent          = dzenColor "" myRED . pad
  52.                 , ppVisible         = dzenColor myYELLOW myBLACK . pad  -- workspace visible on 2nd monitor
  53.                 , ppWsSep           = ""
  54.                 }
  55.             }
  56.  
  57.  
  58. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  59.  
  60.     -- launch a terminal
  61.     [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  62.  
  63.     -- launch dmenu
  64.     --, ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  65.     , ((modm,               xK_p     ), spawn "dmenu_run -fn $FONT -nb $BG -nf $FG -sb $BLACK -sf $FG")
  66.  
  67.     -- launch gmrun#
  68.     , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
  69.  
  70.     -- close focused window
  71.     , ((modm .|. shiftMask, xK_c     ), kill)
  72.  
  73.      -- Rotate through the available layout algorithms
  74.     , ((modm,               xK_space ), sendMessage NextLayout)
  75.  
  76.     --  Reset the layouts on the current workspace to default
  77.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  78.  
  79.     -- Resize viewed windows to the correct size [doesn't seem to be working; reusing bind for pomodoro]
  80.     --, ((modm,               xK_n     ), refresh)
  81.     , ((modm,               xK_n     ), spawn "touch ~/.pomodoro_session")
  82.    
  83.     -- Move focus to the next window
  84.     , ((modm,               xK_Tab   ), windows W.focusDown)
  85.  
  86.     -- Move focus to the next window
  87.     , ((modm,               xK_j     ), windows W.focusDown)
  88.  
  89.     -- Move focus to the previous window
  90.     , ((modm,               xK_k     ), windows W.focusUp  )
  91.  
  92.     -- Move focus to the master window
  93.     , ((modm,               xK_m     ), windows W.focusMaster  )
  94.  
  95.     -- Swap the focused window and the master window
  96.     , ((modm,               xK_Return), windows W.swapMaster)
  97.  
  98.     -- Swap the focused window with the next window
  99.     , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
  100.  
  101.     -- Swap the focused window with the previous window
  102.     , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
  103.  
  104.     -- Shrink the master area
  105.     , ((modm,               xK_h     ), sendMessage Shrink)
  106.  
  107.     -- Expand the master area
  108.     , ((modm,               xK_l     ), sendMessage Expand)
  109.  
  110.     -- Push window back into tiling
  111.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  112.  
  113.     -- Increment the number of windows in the master area
  114.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  115.  
  116.     -- Deincrement the number of windows in the master area
  117.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  118.  
  119.     -- Toggle the status bar gap
  120.     -- Use this binding with avoidStruts from Hooks.ManageDocks.
  121.     -- See also the statusBar function from Hooks.DynamicLog.
  122.     --
  123.     -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
  124.  
  125.     -- Quit xmonad
  126.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  127.  
  128.     -- Restart xmonad
  129.     , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  130.     ]
  131.     ++
  132.  
  133.     --
  134.     -- mod-[1..9], Switch to workspace N
  135.     --
  136.     -- mod-[1..9], Switch to workspace N
  137.     -- mod-shift-[1..9], Move client to workspace N
  138.     --
  139.     [((m .|. modm, k), windows $ f i)
  140.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  141.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  142.         --, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  143.     ++
  144.  
  145.     --
  146.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  147.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  148.     --
  149.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  150.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  151.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  152.  
  153. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  154.  
  155.     -- mod-button1, Set the window to floating mode and move by dragging
  156.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  157.                                        >> windows W.shiftMaster))
  158.  
  159.     -- mod-button2, Raise the window to the top of the stack
  160.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  161.  
  162.     -- mod-button3, Set the window to floating mode and resize by dragging
  163.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  164.                                        >> windows W.shiftMaster))
  165.  
  166.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  167.     ]
  168.  
  169. myLayout = avoidStruts $ smartBorders ( mtiled ||| tiled ||| full )
  170.   where
  171.     tiled   = named " " $ Tall 1 (3/100) (2/(1+(toRational(sqrt(5)::Double)))) -- golden
  172.     mtiled  = named " " $ Mirror tiled
  173.     full    = named "#" $ Full
  174.  
  175. --
  176. -- xprop|egrep "WM_CLASS|WM_NAME"
  177. --
  178. -- WM_CLASS(STRING) 1st > 'resource'
  179. -- WM_CLASS(STRING) 2nd > 'className'
  180. -- WM_NAME(STRING)      > 'title'
  181. --
  182.  
  183. myManageHook = composeAll
  184.     [ title     =? "Accounts"                                                       --> doFloat
  185.     , className =? "Galculator"                                                     --> doFloat
  186.     , className =? "MPlayer"                                                        --> doFloat
  187.     , title     =? "Torrent Options"                                                --> doFloat
  188.     , className =? "VirtualBox"                                                     --> doFloat
  189.     , resource  =? "chromium-browser" <&&> title =? "Google - Bookmarks - Chromium" --> doFloat
  190.     , resource  =? "desktop_window"                                                 --> doIgnore
  191.     , className =? "rdesktop"                                                       --> doFloat
  192.     , className =? "trayer"                                                         --> doIgnore        
  193.     , title     =? "xmessage"                                                       --> doIgnore ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement