Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

xmonad.hs v4

By: nnoell on Oct 12th, 2011  |  syntax: Haskell  |  size: 23.47 KB  |  hits: 194  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --------------------------------------------------------------------------------------------
  2. -- ~/.xmonad/xmonad.hs                                                                    --
  3. -- validate syntax: xmonad --recompile                                                    --
  4. --------------------------------------------------------------------------------------------
  5. -- author: nnoell <nnoell3[at]gmail.com>                                                  --
  6. -- credit: milomouse     -> copied about 60% of his xmonad.hs. Too many thanks to mention --
  7. --         and1          -> config used as my starting grounds                            --
  8. --         count-corrupt -> copied clickable workspaces and clickable layout swithcher    --
  9. --------------------------------------------------------------------------------------------
  10.  
  11. -- Misc
  12. {-# LANGUAGE DeriveDataTypeable, NoMonomorphismRestriction, TypeSynonymInstances, MultiParamTypeClasses #-}
  13.  
  14. -- Imported libraries
  15. import XMonad
  16. import XMonad.Core
  17. import XMonad.Layout
  18. import XMonad.Layout.IM
  19. import XMonad.Layout.Gaps
  20. import XMonad.Layout.Named
  21. import XMonad.Layout.Tabbed
  22. import XMonad.Layout.OneBig
  23. import XMonad.Layout.Master
  24. import XMonad.Layout.Reflect
  25. import XMonad.Layout.MosaicAlt
  26. import XMonad.Layout.NoBorders (noBorders,smartBorders,withBorder)
  27. import XMonad.Layout.ResizableTile
  28. import XMonad.Layout.MultiToggle
  29. import XMonad.Layout.MultiToggle.Instances
  30. import XMonad.Layout.PerWorkspace (onWorkspace)
  31. import XMonad.Layout.Minimize
  32. import XMonad.StackSet (RationalRect (..), currentTag)
  33. import XMonad.Hooks.DynamicLog
  34. import XMonad.Hooks.ManageDocks (avoidStruts,avoidStrutsOn,manageDocks)
  35. import XMonad.Hooks.ManageHelpers
  36. import XMonad.Hooks.UrgencyHook
  37. import XMonad.Hooks.EwmhDesktops
  38. import XMonad.Hooks.SetWMName
  39. import XMonad.Prompt
  40. import XMonad.Prompt.Shell
  41. import XMonad.Prompt.XMonad
  42. import XMonad.Util.Cursor
  43. import XMonad.Util.Run (spawnPipe)
  44. import XMonad.Util.Scratchpad (scratchpadManageHook, scratchpadSpawnActionCustom)
  45. import XMonad.Util.NamedScratchpad
  46. import XMonad.Actions.CycleWS (nextWS, prevWS, toggleWS, toggleOrView)
  47. import XMonad.Actions.GridSelect
  48. import XMonad.Actions.FloatKeys
  49. import Data.Monoid
  50. import Data.List
  51. import Graphics.X11.ExtraTypes.XF86
  52. import System.Exit
  53. import System.IO (Handle, hPutStrLn)
  54. import qualified XMonad.StackSet as W
  55. import qualified Data.Map as M
  56. import qualified XMonad.Actions.FlexibleResize as Flex
  57.  
  58. -- Main
  59. main :: IO ()
  60. main = do
  61.         workspaceBar            <- spawnPipe myWorkspaceBar
  62.         bottomStatusBar         <- spawnPipe myBottomStatusBar
  63.         topStatusBar            <- spawnPipe myTopStatusBar
  64.         xmonad $ myUrgencyHook $ ewmh defaultConfig
  65.                 { terminal           = "urxvtc"
  66.                 , modMask            = mod4Mask
  67.                 , focusFollowsMouse  = True
  68.                 , borderWidth        = 1
  69.                 , normalBorderColor  = myNormalBorderColor
  70.                 , focusedBorderColor = myFocusedBorderColor
  71.                 , layoutHook         = myLayoutHook
  72.                 , workspaces         = myWorkspaces
  73.                 , manageHook         = manageDocks <+> myManageHook
  74.                 , logHook            = myLogHook >> (dynamicLogWithPP $ myDzenPP workspaceBar)
  75.                 , handleEventHook    = fullscreenEventHook
  76.                 , keys               = myKeys
  77.                 , mouseBindings      = myMouseBindings
  78.                 , startupHook        = myStartupHook
  79.                 }
  80.  
  81. -- Colors and fonts
  82. myFont               = "-xos4-terminus-medium-r-normal-*-12-120-72-72-c-60-*-*"
  83. dzenFont             = "-*-montecarlo-medium-r-normal-*-11-*-*-*-*-*-*-*"
  84. colorBlack           = "#020202" --Background (Dzen_BG)
  85. colorBlackAlt        = "#1c1c1c" --Black Xdefaults
  86. colorGray            = "#444444" --Gray       (Dzen_FG2)
  87. colorGrayAlt         = "#161616" --Gray dark
  88. colorWhite           = "#a9a6af" --Foreground (Shell_FG)
  89. colorWhiteAlt        = "#9d9d9d" --White dark (Dzen_FG)
  90. colorMagenta         = "#8e82a2"
  91. colorBlue            = "#3475aa"
  92. colorRed             = "#d74b73"
  93. colorGreen           = "#99cc66"
  94. myArrow              = "^fg(" ++ colorWhiteAlt ++ ")>^fg(" ++ colorBlue ++ ")>^fg(" ++ colorGray ++ ")>"
  95. myNormalBorderColor  = colorBlackAlt
  96. myFocusedBorderColor = colorGray
  97.  
  98. -- Tab theme
  99. myTabTheme = defaultTheme
  100.         { fontName            = myFont
  101.         , inactiveBorderColor = colorBlackAlt
  102.         , inactiveColor       = colorBlack
  103.         , inactiveTextColor   = colorGray
  104.         , activeBorderColor   = colorGray
  105.         , activeColor         = colorBlackAlt
  106.         , activeTextColor     = colorWhiteAlt
  107.         , urgentBorderColor   = colorGray
  108.         , urgentTextColor     = colorGreen
  109.         , decoHeight          = 14
  110.         }
  111.  
  112. -- Prompt theme
  113. myXPConfig = defaultXPConfig
  114.         { font                = myFont
  115.         , bgColor             = colorBlack
  116.         , fgColor             = colorWhite
  117.         , bgHLight            = colorBlue
  118.         , fgHLight            = colorWhite
  119.         , borderColor         = colorGrayAlt
  120.         , promptBorderWidth   = 1
  121.         , height              = 16
  122.         , position            = Top
  123.         , historySize         = 100
  124.         , historyFilter       = deleteConsecutive
  125.         , autoComplete        = Nothing
  126.         }
  127.  
  128. -- GridSelect color scheme
  129. myColorizer = colorRangeFromClassName
  130.         (0x00,0x00,0x00) -- lowest inactive bg
  131.         (0x60,0xA0,0xC0) -- highest inactive bg
  132.         (0x34,0x75,0xAA) -- active bg
  133.         (0xBB,0xBB,0xBB) -- inactive fg
  134.         (0x00,0x00,0x00) -- active fg
  135.         where
  136.                 black = minBound
  137.                 white = maxBound
  138.  
  139. -- GridSelect theme
  140. myGSConfig colorizer = (buildDefaultGSConfig myColorizer)
  141.         { gs_cellheight  = 50
  142.         , gs_cellwidth   = 200
  143.         , gs_cellpadding = 10
  144.         , gs_font        = myFont
  145.         }
  146.  
  147. -- Scratchpad (Alt+ยบ)
  148. manageScratchPad :: ManageHook
  149. manageScratchPad = scratchpadManageHook (W.RationalRect (0) (1/50) (1) (3/4))
  150. scratchPad = scratchpadSpawnActionCustom "urxvtc -name scratchpad"
  151.  
  152. -- Transformers (Ctrl+f)
  153. data TABBED = TABBED deriving (Read, Show, Eq, Typeable)
  154. instance Transformer TABBED Window where
  155.         transform TABBED x k = k (named "TS" (smartBorders (tabbedAlways shrinkText myTabTheme))) (\_ -> x)
  156.  
  157. -- StartupHook
  158. myStartupHook = setWMName "LG3D" >> setDefaultCursor xC_left_ptr
  159.  
  160. -- LogHook (needed for running java apps)
  161. myLogHook = ewmhDesktopsLogHook >> setWMName "LG3D"
  162.  
  163. -- UrgencyHook
  164. myUrgencyHook = withUrgencyHook dzenUrgencyHook
  165.         { args = ["-fn", dzenFont, "-bg", colorBlack, "-fg", colorGreen] }
  166.  
  167. -- StatusBars
  168. myWorkspaceBar, myBottomStatusBar, myTopStatusBar :: String
  169. myWorkspaceBar    = "dzen2 -x '0' -y '784' -h '16' -w '890' -ta 'l' -fg '" ++ colorWhiteAlt ++ "' -bg '" ++ colorBlack ++ "' -fn '" ++ dzenFont ++ "' -p -e ''"
  170. myBottomStatusBar = "/home/nnoell/bin/bottomstatusbar.sh"
  171. myTopStatusBar    = "/home/nnoell/bin/topstatusbar.sh"
  172.  
  173. -- Workspaces
  174. myWorkspaces :: [WorkspaceId]
  175. myWorkspaces = --clickable $ --clickable workspaces now declared in myDzenPP
  176.         ["TERM"  --0
  177.         ,"WEBS"  --1
  178.         ,"CODE"  --2
  179.         ,"GRFX"  --3
  180.         ,"CHAT"  --4
  181.         ,"GAME"  --5
  182.         ,"VIDS"  --6
  183.         ,"OTHR"  --7
  184.         ]
  185. --      where clickable l = [ "^ca(1,xdotool key super+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
  186. --              (i,ws) <- zip [1..] l,
  187. --              let n = if i == 10 then 0 else i ]
  188.  
  189. -- Layout hook
  190. myLayoutHook = id
  191.         $ gaps [(U,16), (D,16), (L,0), (R,0)]
  192.         $ avoidStruts
  193.         $ minimize
  194.         $ mkToggle (single TABBED)
  195.         $ mkToggle (single MIRROR)
  196.         $ mkToggle (single REFLECTX)
  197.         $ mkToggle (single REFLECTY)
  198.         $ onWorkspace (myWorkspaces !! 1) webLayouts  --Workspace 1 layouts
  199.         $ onWorkspace (myWorkspaces !! 2) codeLayouts --Workspace 2 layouts
  200.         $ onWorkspace (myWorkspaces !! 3) gimpLayouts --Workspace 3 layouts
  201.         $ onWorkspace (myWorkspaces !! 4) chatLayouts --Workspace 4 layouts
  202.         $ allLayouts
  203.         where
  204.                 allLayouts  = myTile ||| myObig ||| myMirr ||| myMosA ||| myTabM
  205.                 webLayouts  = myTabs ||| myTabM
  206.                 codeLayouts = myTabM ||| myTile
  207.                 gimpLayouts = myGimp
  208.                 chatLayouts = myChat
  209.                 --Layouts
  210.                 myTile = named "T"  (smartBorders (ResizableTall 1 0.03 0.5 []))
  211.                 myMirr = named "MT" (smartBorders (Mirror myTile))
  212.                 myMosA = named "M"  (smartBorders (MosaicAlt M.empty))
  213.                 myObig = named "O"  (smartBorders (OneBig 0.75 0.65))
  214.                 myTabs = named "TS" (smartBorders (tabbed shrinkText myTabTheme))
  215.                 myTabM = named "TM" (smartBorders (mastered 0.01 0.4 $ (tabbed shrinkText myTabTheme)))
  216.                 myGimp = named "G"  (withIM (0.15) (Role "gimp-toolbox") $ reflectHoriz $ withIM (0.20) (Role "gimp-dock") (myMosA))
  217.                 myChat = named "C"  (withIM (0.20) (Title "Buddy List") $ Mirror myTile)
  218.  
  219. -- Manage hook
  220. myManageHook :: ManageHook
  221. myManageHook = (composeAll . concat $
  222.         [ [resource     =? r     --> doIgnore                             | r <- myIgnores] --ignore desktop
  223.         , [className    =? c     --> doShift (myWorkspaces !! 1)          | c <- myWebS   ] --move myWebS windows to workspace 1 by classname
  224.         , [className    =? c     --> doShift (myWorkspaces !! 4)          | c <- myChatS  ] --move myChatS windows to workspace 4 by classname
  225.         , [className    =? c     --> doShift (myWorkspaces !! 3)          | c <- myGfxS   ] --move myGfxS windows to workspace 4 by classname
  226.         , [className    =? c     --> doShiftAndGo (myWorkspaces !! 5)     | c <- myGameS  ] --move myGameS windows to workspace 5 by classname
  227.         , [className    =? c     --> doCenterFloat                        | c <- myFloatCC] --float center geometry by classname
  228.         , [name         =? n     --> doCenterFloat                        | n <- myFloatCN] --float center geometry by name
  229.         , [name         =? n     --> doSideFloat NW                       | n <- myFloatSN] --float side NW geometry by name
  230.         , [className    =? c     --> doF W.focusDown                      | c <- myFocusDC] --dont focus on launching by classname
  231.         , [isFullscreen          --> doF W.focusDown <+> doFullFloat]
  232.         ]) <+> manageScratchPad
  233.         where
  234.                 doShiftAndGo ws = doF (W.greedyView ws) <+> doShift ws
  235.                 role            = stringProperty "WM_WINDOW_ROLE"
  236.                 name            = stringProperty "WM_NAME"
  237.                 myIgnores       = ["desktop","desktop_window"]
  238.                 myWebS          = ["Chromium","Firefox"]
  239.                 myGfxS          = ["gimp-2.6", "Gimp-2.6", "Gimp", "gimp", "GIMP"]
  240.                 myChatS         = ["Pidgin", "Xchat"]
  241.                 myGameS         = ["zsnes", "jpcsp-MainGUI", "Desmume"]
  242.                 myFloatCC       = ["MPlayer", "File-roller", "zsnes", "Gcalctool", "Exo-helper-1", "Gksu", "PSX", "Galculator", "Nvidia-settings", "XFontSel", "XCalc", "XClock", "Desmume", "Ossxmix", "Xvidcap"]
  243.                 myFloatCN       = ["ePSXe - Enhanced PSX emulator", "Seleccione Archivo", "Config Video", "Testing plugin", "Config Sound", "Config Cdrom", "Config Bios", "Config Netplay", "Config Memcards", "About ePSXe", "Config Controller", "Config Gamepads", "Select one or more files to open", "Add media", "Choose a file", "Open Image", "File Operation Progress", "Firefox Preferences", "Preferences", "Search Engines", "Set up sync", "Passwords and Exceptions", "Autofill Options", "Rename File", "Copying files", "Moving files", "File Properties", "Replace", ""]
  244.                 myFloatSN       = ["Event Tester"]
  245.                 myFocusDC       = ["Event Tester", "Notify-osd"]
  246.  
  247. -- myWorkspaceBar config
  248. myDzenPP h = defaultPP
  249.         { ppOutput          = hPutStrLn h
  250.         , ppSort            = fmap (namedScratchpadFilterOutWorkspace.) (ppSort defaultPP) -- hide "NSP" from workspace list
  251.         , ppOrder           = \(ws:l:t:_) -> [ws,l,t]
  252.         , ppExtras          = []
  253.         , ppSep             = "^fg(" ++ colorGray ++ ")|"
  254.         , ppWsSep           = ""
  255.         , ppCurrent         = dzenColor colorBlue     colorBlack . pad
  256.         , ppUrgent          = dzenColor colorGreen    colorBlack . pad . wrapClickWorkSpace . (\a -> (a,a))
  257.         , ppVisible         = dzenColor colorGray         colorBlack . pad . wrapClickWorkSpace . (\a -> (a,a))
  258.         , ppHidden          = dzenColor colorWhiteAlt colorBlack . pad . wrapClickWorkSpace . (\a -> (a,a))
  259.         , ppHiddenNoWindows = dzenColor colorGray         colorBlack . pad . wrapClickWorkSpace . (\a -> (a,a))
  260.         , ppTitle           = dzenColor colorWhiteAlt colorBlack . pad . wrapClickTitle .
  261.                 (\x -> if null x
  262.                         then "Desktop " ++ myArrow ++ ""
  263.                         else "" ++ shorten 85 x ++ " " ++ myArrow ++ ""
  264.                 ) . dzenEscape
  265.         , ppLayout          = dzenColor colorBlue     colorBlack . pad . wrapClickLayout .
  266.                 (\x -> case x of
  267.                         "Minimize T"                    -> "ReTall"
  268.                         "Minimize O"                    -> "OneBig"
  269.                         "Minimize TS"                   -> "Tabbed"
  270.                         "Minimize TM"                   -> "Master"
  271.                         "Minimize M"                    -> "Mosaic"
  272.                         "Minimize MT"                   -> "Mirror"
  273.                         "Minimize G"                    -> "Mosaic"
  274.                         "Minimize C"                    -> "Mirror"
  275.                         "Minimize ReflectX T"           -> "^fg(" ++ colorGreen ++ ")ReTall X^fg()"
  276.                         "Minimize ReflectX O"           -> "^fg(" ++ colorGreen ++ ")OneBig X^fg()"
  277.                         "Minimize ReflectX TS"          -> "^fg(" ++ colorGreen ++ ")Tabbed X^fg()"
  278.                         "Minimize ReflectX TM"          -> "^fg(" ++ colorGreen ++ ")Master X^fg()"
  279.                         "Minimize ReflectX M"           -> "^fg(" ++ colorGreen ++ ")Mosaic X^fg()"
  280.                         "Minimize ReflectX MT"          -> "^fg(" ++ colorGreen ++ ")Mirror X^fg()"
  281.                         "Minimize ReflectX G"           -> "^fg(" ++ colorGreen ++ ")Mosaic X^fg()"
  282.                         "Minimize ReflectX C"           -> "^fg(" ++ colorGreen ++ ")Mirror X^fg()"
  283.                         "Minimize ReflectY T"           -> "^fg(" ++ colorGreen ++ ")ReTall Y^fg()"
  284.                         "Minimize ReflectY O"           -> "^fg(" ++ colorGreen ++ ")OneBig Y^fg()"
  285.                         "Minimize ReflectY MT"          -> "^fg(" ++ colorGreen ++ ")Tabbed Y^fg()"
  286.                         "Minimize ReflectY TM"          -> "^fg(" ++ colorGreen ++ ")Master Y^fg()"
  287.                         "Minimize ReflectY M"           -> "^fg(" ++ colorGreen ++ ")Mosaic Y^fg()"
  288.                         "Minimize ReflectY MT"          -> "^fg(" ++ colorGreen ++ ")Mirror Y^fg()"
  289.                         "Minimize ReflectY G"           -> "^fg(" ++ colorGreen ++ ")Mosaic Y^fg()"
  290.                         "Minimize ReflectY C"           -> "^fg(" ++ colorGreen ++ ")Mirror Y^fg()"
  291.                         "Minimize ReflectX ReflectY T"  -> "^fg(" ++ colorGreen ++ ")ReTall XY^fg()"
  292.                         "Minimize ReflectX ReflectY O"  -> "^fg(" ++ colorGreen ++ ")OneBig XY^fg()"
  293.                         "Minimize ReflectX ReflectY TS" -> "^fg(" ++ colorGreen ++ ")Tabbed XY^fg()"
  294.                         "Minimize ReflectX ReflectY TM" -> "^fg(" ++ colorGreen ++ ")Master XY^fg()"
  295.                         "Minimize ReflectX ReflectY M"  -> "^fg(" ++ colorGreen ++ ")Mosaic XY^fg()"
  296.                         "Minimize ReflectX ReflectY MT" -> "^fg(" ++ colorGreen ++ ")Mirror XY^fg()"
  297.                         "Minimize ReflectX ReflectY G"  -> "^fg(" ++ colorGreen ++ ")Mosaic XY^fg()"
  298.                         "Minimize ReflectX ReflectY C"  -> "^fg(" ++ colorGreen ++ ")Mirror XY^fg()"
  299.                         _                               -> "^fg(" ++ colorGreen ++ ")" ++ x ++ "^fg()" --Only for Mirror
  300.                 )
  301.         }
  302.         where
  303.                 --clickable workspaces, layout and title (thanks to count-corrupt). Carefull, tabulations will be evaluated
  304.                 wrapClickLayout content = "^ca(1,xdotool key super+space)" ++ content ++ "^ca()"
  305.                 wrapClickTitle content = "^ca(1,xdotool key super+j)" ++ content ++ "^ca()"
  306.                 currentWsIndex w = case (elemIndex w myWorkspaces) of
  307.                         Nothing -> "1"
  308.                         Just n -> show (n+1)
  309.                 wrapClickWorkSpace (idx,str) = "^ca(1," ++ xdo "w;" ++ xdo index ++ ")" ++ "^ca(3," ++ xdo "e;" ++ xdo index ++ ")" ++ str ++ "^ca()^ca()"
  310.                         where
  311.                                 index = currentWsIndex idx
  312.                                 xdo key = "xdotool key super+" ++ key
  313.  
  314. -- Key bindings
  315. myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
  316. myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  317.         [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)                       --Launch a terminal
  318.         , ((mod1Mask, xK_F2), shellPrompt myXPConfig)                                              --Launch Xmonad shell prompt
  319.         , ((modMask, xK_F2), xmonadPrompt myXPConfig)                                              --Launch Xmonad prompt
  320.         , ((modMask, xK_g), goToSelected $ myGSConfig myColorizer)                                 --Launch GridSelect
  321.         , ((modMask, xK_masculine), scratchPad)                                                    --Scratchpad
  322.         , ((modMask, xK_o), spawn "gksu halt")                                                     --Power off
  323.         , ((modMask .|. shiftMask, xK_o), spawn "gksu reboot")                                     --Reboot
  324.         , ((mod1Mask, xK_F3), spawn "chromium")                                                    --Launch chromium
  325.         , ((modMask, xK_c), kill)                                                                  --Close focused window
  326.         , ((mod1Mask, xK_F4), kill)
  327.         , ((modMask, xK_space), sendMessage NextLayout)                                            --Rotate through the available layout algorithms
  328.         , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)                 --Reset the layouts on the current workspace to default
  329.         , ((modMask, xK_n), refresh)                                                               --Resize viewed windows to the correct size
  330.         , ((modMask, xK_Tab), windows W.focusDown)                                                 --Move focus to the next window
  331.         , ((modMask, xK_j), windows W.focusDown)
  332.         , ((mod1Mask, xK_Tab), windows W.focusDown)
  333.         , ((modMask, xK_k), windows W.focusUp)                                                     --Move focus to the previous window
  334.         , ((modMask, xK_a), windows W.focusMaster)                                                 --Move focus to the master window
  335.         , ((modMask .|. shiftMask, xK_a), windows W.swapMaster)                                    --Swap the focused window and the master window
  336.         , ((modMask .|. shiftMask, xK_j), windows W.swapDown  )                                    --Swap the focused window with the next window
  337.         , ((modMask .|. shiftMask, xK_k), windows W.swapUp    )                                    --Swap the focused window with the previous window
  338.         , ((modMask, xK_h), sendMessage Shrink)                                                    --Shrink the master area
  339.         , ((modMask .|. shiftMask, xK_Left), sendMessage Shrink)
  340.         , ((modMask, xK_l), sendMessage Expand)                                                    --Expand the master area
  341.         , ((modMask .|. shiftMask, xK_Right), sendMessage Expand)
  342.         , ((modMask .|. shiftMask, xK_h), sendMessage MirrorShrink)                                --MirrorShrink the master area
  343.         , ((modMask .|. shiftMask, xK_Down), sendMessage MirrorShrink)
  344.         , ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand)                                --MirrorExpand the master area
  345.         , ((modMask .|. shiftMask, xK_Up), sendMessage MirrorExpand)
  346.         , ((modMask .|. controlMask, xK_Left), withFocused (keysResizeWindow (-30,0) (0,0)))       --Shrink floated window horizontally by 50 pixels
  347.         , ((modMask .|. controlMask, xK_Right), withFocused (keysResizeWindow (30,0) (0,0)))       --Expand floated window horizontally by 50 pixels
  348.         , ((modMask .|. controlMask, xK_Up), withFocused (keysResizeWindow (0,-30) (0,0)))         --Shrink floated window verticaly by 50 pixels
  349.         , ((modMask .|. controlMask, xK_Down), withFocused (keysResizeWindow (0,30) (0,0)))        --Expand floated window verticaly by 50 pixels
  350.         , ((modMask, xK_t), withFocused $ windows . W.sink)                                        --Push window back into tiling
  351.         , ((modMask .|. shiftMask, xK_t), rectFloatFocused)                                        --Push window into float
  352.         , ((modMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle TABBED)                 --Push layout into tabbed
  353.         , ((modMask .|. shiftMask, xK_z), sendMessage $ Toggle MIRROR)                             --Push layout into mirror
  354.         , ((modMask .|. shiftMask, xK_x), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTX) --Reflect layout by X
  355.         , ((modMask .|. shiftMask, xK_y), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTY) --Reflect layout by Y
  356.         , ((modMask, xK_m), withFocused minimizeWindow)                                            --Minimize window
  357.         , ((modMask .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin)                     --Restore window
  358.         , ((modMask .|. shiftMask, xK_f), fullFloatFocused)                                        --Push window into full screen
  359.         , ((modMask, xK_comma), sendMessage (IncMasterN 1))                                        --Increment the number of windows in the master area
  360.         , ((modMask, xK_period), sendMessage (IncMasterN (-1)))                                    --Deincrement the number of windows in the master area
  361.         , ((modMask , xK_d), spawn "killall dzen2 trayer")                                         --Kill dzen2 and trayer
  362.         , ((modMask , xK_s), spawn "xscreensaver-command -lock")                                   --Lock screen
  363.         , ((modMask .|. shiftMask, xK_q), io (exitWith ExitSuccess))                               --Quit xmonad
  364.         , ((modMask, xK_q), restart "xmonad" True)                                                 --Restart xmonad
  365.         , ((modMask, xK_comma), toggleWS)                                                          --Toggle to the workspace displayed previously
  366.         , ((mod1Mask, xK_masculine), toggleOrView (myWorkspaces !! 0))                             --if ws != 0 then move to workspace 0, else move to latest ws I was
  367.         , ((mod1Mask .|. controlMask, xK_Left),  prevWS)                                           --Move to previous Workspace
  368.         , ((modMask, xK_Left), prevWS)
  369.         , ((modMask, xK_Right), nextWS)                                                            --Move to next Workspace
  370.         , ((mod1Mask .|. controlMask, xK_Right), nextWS)
  371.         , ((0, xF86XK_AudioMute), spawn "sh /home/nnoell/bin/volosd.sh mute")                      --Mute/unmute volume
  372.         , ((0, xF86XK_AudioRaiseVolume), spawn "sh /home/nnoell/bin/volosd.sh up")                 --Raise volume
  373.         , ((0, xF86XK_AudioLowerVolume), spawn "sh /home/nnoell/bin/volosd.sh down")               --Lower volume
  374.         , ((0, xF86XK_AudioNext), spawn "ncmpcpp next")                                            --next song
  375.         , ((0, xF86XK_AudioPrev), spawn "ncmpcpp prev")                                            --prev song
  376.         , ((0, xF86XK_AudioPlay), spawn "ncmpcpp toggle")                                          --toggle song
  377.         , ((0, xF86XK_AudioStop), spawn "ncmpcpp stop")                                            --stop song
  378.         , ((0, xF86XK_MonBrightnessUp), spawn "sh /home/nnoell/bin/briosd.sh")                     --Raise brightness
  379.         , ((0, xF86XK_MonBrightnessDown), spawn "sh /home/nnoell/bin/briosd.sh")                   --Lower brightness
  380.         , ((0, xF86XK_ScreenSaver), spawn "xscreensaver-command -lock")                            --Lock screen
  381.         , ((0, xK_Print), spawn "scrot '%Y-%m-%d_$wx$h.png'")                                      --Take a screenshot
  382.         ]
  383.         ++
  384.         [((m .|. modMask, k), windows $ f i)                                                       --Switch to n workspaces and send client to n workspaces
  385.                 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  386.                 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  387.         ++
  388.         [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))                --Switch to n screens and send client to n screens
  389.                 | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  390.                 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  391.         where
  392.                 fullFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery doFullFloat f
  393.                 rectFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery (doRectFloat $ RationalRect 0.05 0.05 0.9 0.9) f
  394.  
  395. -- Mouse bindings
  396. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  397.         [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) -- set the window to floating mode and move by dragging
  398.         , ((modMask, button2), (\w -> focus w >> windows W.shiftMaster))                      -- raise the window to the top of the stack
  399.         , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))                   -- set the window to floating mode and resize by dragging
  400.         , ((modMask, button4), (\_ -> prevWS))                                                -- switch to previous workspace
  401.         , ((modMask, button5), (\_ -> nextWS))                                                -- switch to next workspace
  402.         ]