Advertisement
kamaradclimber

Untitled

Aug 11th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.18 KB | None | 0 0
  1. {-# LANGUAGE NoMonomorphismRestriction #-}
  2.  
  3. -- {{{ Imports
  4. import XMonad
  5. import qualified XMonad.Actions.ConstrainedResize as Sqr
  6. import XMonad.Actions.CycleWS
  7. import XMonad.Actions.DwmPromote
  8. import XMonad.Actions.FindEmptyWorkspace
  9. import XMonad.Actions.NoBorders
  10. import XMonad.Config.Azerty
  11. import XMonad.Hooks.DynamicLog
  12. import XMonad.Hooks.FadeInactive
  13. import XMonad.Hooks.ManageDocks
  14. import XMonad.Hooks.UrgencyHook
  15. import XMonad.Layout.Accordion
  16. import XMonad.Layout.Decoration
  17. import XMonad.Layout.Grid
  18. import XMonad.Layout.Maximize
  19. import XMonad.Layout.NoBorders
  20. import XMonad.Layout.PerWorkspace
  21. import XMonad.Layout.StackTile
  22. import XMonad.Layout.Tabbed
  23. import XMonad.Layout.WindowNavigation
  24. import XMonad.Prompt
  25. --import XMonad.Prompt.RunOrRaise
  26. --import XMonad.Prompt.Shell
  27. import qualified XMonad.StackSet as W
  28. import XMonad.Util.Loggers
  29. import XMonad.Util.Run(spawnPipe)
  30. import XMonad.Util.Scratchpad
  31. import XMonad.Util.EZConfig(additionalKeys)
  32.  
  33. import qualified Data.Map as M
  34. import Data.Monoid
  35.  
  36.  
  37. import System.Exit
  38. import System.IO
  39. -- }}}
  40.  
  41. myTerminal = "urxvt"
  42. myBrowser = "chromium"
  43. myWorkspaces = map show [1..9]
  44.  
  45. myBorderWidth = 1
  46. myNormalBorderColor = "#dddddd"
  47. myFocusedBorderColor = "#ff0000"
  48.  
  49. -- Whether focus follows the mouse pointer.
  50. myFocusFollowsMouse :: Bool
  51. myFocusFollowsMouse = True
  52.  
  53.  
  54. -- modMask lets you specify which modkey you want to use. The default
  55. -- is mod1Mask ("left alt"). You may also consider using mod3Mask
  56. -- ("right alt"), which does not conflict with emacs keybindings. The
  57. -- "windows key" is usually mod4Mask.
  58. myModMask = mod4Mask
  59.  
  60. -- The mask for the numlock key. Numlock status is "masked" from the
  61. -- current modifier status, so the keybindings will work with numlock on or
  62. -- off. You may need to change this on some systems.
  63. --
  64. -- You can find the numlock modifier by running "xmodmap" and looking for a
  65. -- modifier with Num_Lock bound to it:
  66. --
  67. -- > $ xmodmap | grep Num
  68. -- > mod2 Num_Lock (0x4d)
  69. --
  70.  
  71. --
  72.  
  73.  
  74. -- {{{ Key bindings
  75. myKeys = \c -> azertyKeys c `M.union` generalKeys c
  76.  
  77.  
  78. generalKeys conf@(XConfig {XMonad.modMask = modm }) = M.fromList $ [
  79. -- Spawn programs
  80. ((modm, xK_Return), spawn $ XMonad.terminal conf),
  81. ((modm, xK_a), scratchpadSpawnActionTerminal $ XMonad.terminal conf),
  82. ((modm, xK_c), spawn myBrowser),
  83. ((modm, xK_F4), kill),
  84.  
  85. -- Layouts
  86. ((modm, xK_space), sendMessage NextLayout),
  87. ((modm .|. shiftMask, xK_space), setLayout $ XMonad.layoutHook conf),
  88. ((modm, xK_n), refresh),
  89.  
  90.  
  91. -- Focus
  92. ((modm, xK_Tab), windows W.focusDown),
  93. ((modm, xK_Page_Down), windows W.focusDown),
  94. ((modm, xK_Page_Up), windows W.focusUp),
  95. --((modm, xK_m), windows W.focusMaster),
  96. ((modm , xK_u), focusUrgent),
  97.  
  98. -- Swap focused window
  99. --((modm, xK_Return), windows W.swapMaster),
  100. --((modm .|. shiftMask, xK_j ), windows W.swapDown ),
  101. --((modm .|. shiftMask, xK_k ), windows W.swapUp ),
  102. ((modm .|. shiftMask, xK_Return), dwmpromote),
  103.  
  104. -- Resize
  105. ((modm, xK_Left), sendMessage Shrink),
  106. ((modm, xK_Right), sendMessage Expand),
  107. -- Push window back into tiling
  108. ((modm .|. shiftMask, xK_t), withFocused $ windows . W.sink),
  109.  
  110.  
  111. -- Toggle the status bar gap
  112. ((modm, xK_b), sendMessage ToggleStruts),
  113.  
  114. ((modm, xK_z), withFocused toggleBorder ),
  115. ((modm, xK_F11), withFocused (sendMessage . maximizeRestore)),
  116.  
  117.  
  118. ((modm .|. shiftMask, xK_q), io (exitWith ExitSuccess)),
  119. ((modm , xK_F5), spawn "xmonad --recompile; xmonad --restart")
  120. ]
  121. -- }}}
  122.  
  123. -- {{{ Mouse bindings
  124. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $ [
  125. -- mod-button1, Set the window to floating mode and move by dragging
  126. ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  127. >> windows W.shiftMaster)),
  128. -- mod-button2, Raise the window to the top of the stack
  129. ((modm, button2), (\w -> focus w >> windows W.shiftMaster)),
  130. -- mod-button3, Set the window to floating mode and resize by dragging
  131. --, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  132. -- >> windows W.shiftMaster))
  133. ((modm, button3), (\w -> focus w >> Sqr.mouseResizeWindow w False)),
  134. ((modm .|. shiftMask, button3), (\w -> focus w >> Sqr.mouseResizeWindow w True ))
  135. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  136. ]
  137. -- }}}
  138.  
  139. -- {{{ Layouts
  140. -- If you change layout bindings be sure to use 'mod-shift-space' after
  141. -- restarting (with 'mod-q') to reset your layout state to the new
  142. -- defaults, as xmonad preserves your old layout settings by default.
  143. webLayout = avoidStruts . smartBorders . windowNavigation $ tiled ||| Mirror tiled ||| Grid ||| Full
  144. defaultLayout = webLayout
  145.  
  146. myLayout = onWorkspace "web" webLayout defaultLayout
  147.  
  148. tiled = Tall nmaster delta ratio
  149. where
  150. nmaster = 1 -- Windows in the master pane
  151. ratio = 1/2 -- Proportion of screen occupied by master pane
  152. delta = 3/100 -- Percent of screen to increment by when resizing panes
  153. stack = StackTile 1 (3/100) (1/2)
  154.  
  155. tabTheme = Theme {
  156. activeColor = "#000077",
  157. inactiveColor = "#000000",
  158. urgentColor = "#770000",
  159. activeBorderColor = "#000077",
  160. inactiveBorderColor = "#111111",
  161. urgentBorderColor = "#777700",
  162. activeTextColor = "#ffffff",
  163. inactiveTextColor = "#aaaaaa",
  164. urgentTextColor = "#ffff00",
  165. fontName = "xft:Inconsolata:pixelsize=14",
  166. decoWidth = 200,
  167. decoHeight = 20
  168. }
  169. -- }}}
  170.  
  171. -- {{{ Window rules
  172. -- Execute arbitrary actions and WindowSet manipulations when managing
  173. -- a new window. You can use this to, for example, always float a
  174. -- particular program, or have a client always appear on a particular
  175. -- workspace.
  176. --
  177. -- To find the property name associated with a program, use
  178. -- > xprop | grep WM_CLASS
  179. --
  180. -- To match on the WM_NAME, you can use 'title' in the same way that
  181. -- 'className' and 'resource' are used below.
  182. floatingWindows = composeAll [
  183. --className =? "MPlayer" --> doFloat,
  184. className =? "Gimp" --> doFloat]
  185.  
  186. ignoredWindows = composeAll [
  187. resource =? "desktop_window" --> doIgnore,
  188. resource =? "kdesktop" --> doIgnore ]
  189.  
  190. moveToWorkspace = composeAll [
  191. resource =? "Chromium" --> doF (W.shift "web") ]
  192.  
  193. manageScratchPad :: ManageHook
  194. manageScratchPad = scratchpadManageHook (W.RationalRect l t w h)
  195. where
  196. h = 0.4 -- terminal height
  197. w = 0.60 -- terminal width
  198. t = 1 - h -- distance from top edge
  199. l = (1 - w)/2 -- distance from left edge
  200.  
  201. onNewWindow =
  202. manageDocks <+>
  203. floatingWindows <+>
  204. ignoredWindows <+>
  205. moveToWorkspace <+>
  206. manageScratchPad
  207. -- }}}
  208.  
  209. ------------------------------------------------------------------------
  210. -- Event handling
  211.  
  212. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  213. --
  214. -- Defines a custom handler function for X Events. The function should
  215. -- return (All True) if the default handler is to be run afterwards. To
  216. -- combine event hooks use mappend or mconcat from Data.Monoid.
  217. myEventHook = docksEventHook
  218.  
  219. -- {{{ Status bars and logging
  220. myLogHook pipe = do
  221. dynamicLogWithPP $ statusInfo pipe
  222. fadeInactiveLogHook 0.7
  223.  
  224. -- myINBOX = "/home/grego/Mail/Gmail/INBOX"
  225. --tagL l = onLogger $ wrap (l++ ": ") ""
  226. --myEmails = [tagL "U" $ maildirUnread myINBOX, tagL "N"$ maildirNew myINBOX ]
  227.  
  228. --myExtras = [date "%R", padL loadAvg] ++ myEmails
  229.  
  230. statusInfo pipe = defaultPP {
  231. ppCurrent = dzenColor "lightblue" "#0000aa",
  232. ppVisible = wrap "(" ")",
  233. ppHidden = (\i -> case i of
  234. "NSP" -> ""
  235. _ -> i),
  236. ppHiddenNoWindows = \_ -> "",
  237. ppUrgent = dzenColor "yellow" "red",
  238. ppSep = " | ",
  239. ppWsSep = " ",
  240. ppTitle = dzenColor "#7777ff" "" . shorten 30,
  241. ppOrder = \(ws:_:_:rest) -> [ws]++rest,
  242. ppOutput = hPutStrLn pipe
  243. -- , ppExtras = myExtras
  244. }
  245. -- }}}
  246.  
  247. ------------------------------------------------------------------------
  248. -- Startup hook
  249.  
  250. -- Perform an arbitrary action each time xmonad starts or is restarted
  251. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  252. -- per-workspace layout choices.
  253. myStartupHook = return ()
  254.  
  255. myUrgencyHook = withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] }
  256.  
  257. -- {{{ Entry point
  258. main = do
  259. dzenPipe <- spawnPipe "dzen2 -fg \"#7777aa\" -bg \"#000033\" -fn \"Inconsolata:pixelsize=16\" -ta \"l\" -expand \"r\""
  260. _ <- spawn myTerminal
  261. xmonad $ myUrgencyHook $ defaults dzenPipe
  262.  
  263. -- A structure containing your configuration settings, overriding
  264. -- fields in the default config. Any you don't override, will
  265. -- use the defaults defined in xmonad/XMonad/Config.hs
  266. defaults pipe = defaultConfig {
  267. -- simple stuff
  268. terminal = myTerminal,
  269. focusFollowsMouse = myFocusFollowsMouse,
  270. borderWidth = myBorderWidth,
  271. modMask = myModMask,
  272. workspaces = myWorkspaces,
  273. normalBorderColor = myNormalBorderColor,
  274. focusedBorderColor = myFocusedBorderColor,
  275.  
  276. -- key bindings
  277. keys = myKeys,
  278. mouseBindings = myMouseBindings,
  279.  
  280. -- hooks, layouts
  281. layoutHook = myLayout,
  282. manageHook = onNewWindow,
  283. handleEventHook = myEventHook,
  284. logHook = myLogHook pipe,
  285. startupHook = myStartupHook
  286. }
  287. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement