Guest User

Untitled

a guest
Apr 12th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. import System.IO
  2. import System.Exit
  3. import XMonad
  4. import XMonad.Hooks.DynamicLog
  5. import XMonad.Hooks.ManageDocks
  6. import XMonad.Hooks.ManageHelpers
  7. import XMonad.Hooks.SetWMName
  8. import XMonad.Layout.Fullscreen
  9. import XMonad.Layout.NoBorders
  10. import XMonad.Layout.SimplestFloat
  11. import XMonad.Layout.Spacing
  12. import XMonad.Layout.Spiral
  13. import XMonad.Layout.PerWorkspace(onWorkspace)
  14. import XMonad.Layout.Tabbed
  15. import XMonad.Util.Run(spawnPipe)
  16. import XMonad.Util.EZConfig(additionalKeys)
  17. import qualified XMonad.StackSet as W
  18. import qualified Data.Map as M
  19.  
  20.  
  21. ------------------------------------------------------------------------
  22. -- Terminal
  23. -- The preferred terminal program, which is used in a binding below and by
  24. -- certain contrib modules.
  25. --
  26. myTerminal = "/usr/bin/urxvt"
  27.  
  28.  
  29. ------------------------------------------------------------------------
  30. -- Workspaces
  31. -- The default number of workspaces (virtual screens) and their names.
  32. --
  33. myWorkspaces = ["one","two","three","four","five"] ++ map show [6..9]
  34.  
  35.  
  36. ------------------------------------------------------------------------
  37. -- Window rules
  38. -- Execute arbitrary actions and WindowSet manipulations when managing
  39. -- a new window. You can use this to, for example, always float a
  40. -- particular program, or have a client always appear on a particular
  41. -- workspace.
  42. --
  43. -- To find the property name associated with a program, use
  44. -- > xprop | grep WM_CLASS
  45. -- and click on the client you're interested in.
  46. --
  47. -- To match on the WM_NAME, you can use 'title' in the same way that
  48. -- 'className' and 'resource' are used below.
  49. --
  50. myManageHook = composeAll
  51. [ resource =? "desktop_window" --> doIgnore
  52. , className =? "Galculator" --> doFloat
  53. , className =? "Steam" --> doFloat
  54. , className =? "Gimp" --> doFloat
  55. , resource =? "gpicview" --> doFloat
  56. , className =? "MPlayer" --> doFloat
  57. , className =? "Download" --> doFloat
  58. , className =? "Progress" --> doFloat
  59. , className =? "steam" --> doFullFloat -- bigpicture-mode
  60. , title =? "Steam_Login" --> doFloat
  61. , className =? "Steam" --> doShift "three"
  62. , title =? "Steam_Login" --> doShift "three"
  63. -- , isFullscreen --> (doF W.focusDown <+> doFullFloat)]
  64. , isFullscreen --> doFullFloat ]
  65.  
  66. ------------------------------------------------------------------------
  67. -- Layouts
  68. -- You can specify and transform your layouts by modifying these values.
  69. -- If you change layout bindings be sure to use 'mod-shift-space' after
  70. -- restarting (with 'mod-q') to reset your layout state to the new
  71. -- defaults, as xmonad preserves your old layout settings by default.
  72. --
  73. -- The available layouts. Note that each layout is separated by |||,
  74. -- which denotes layout choice.
  75. --
  76. defaultLayouts = avoidStruts (
  77. spacing 5 $ Tall 1 (3/100) (1/2) |||
  78. Tall 1 (3/100) (1/2) |||
  79. Mirror (Tall 1 (3/100) (1/2)) |||
  80. tabbed shrinkText tabConfig |||
  81. Full |||
  82. spiral (6/7)) |||
  83. noBorders (fullscreenFull Full)
  84.  
  85. ------------------------------------------------------------------------
  86. -- Colors and borders
  87. --
  88. myNormalBorderColor = "#002b36"
  89. myFocusedBorderColor = "#657b83"
  90.  
  91. -- Colors for text and backgrounds of each tab when in "Tabbed" layout.
  92. tabConfig = defaultTheme {
  93. activeBorderColor = "#7C7C7C",
  94. activeTextColor = "#CEFFAC",
  95. activeColor = "#000000",
  96. inactiveBorderColor = "#7C7C7C",
  97. inactiveTextColor = "#EEEEEE",
  98. inactiveColor = "#000000"
  99. }
  100.  
  101. -- Color of current window title in xmobar.
  102. xmobarTitleColor = "green"
  103.  
  104. -- Color of current workspace in xmobar.
  105. xmobarCurrentWorkspaceColor = "#CEFFAC"
  106.  
  107. -- Width of the window border in pixels.
  108. myBorderWidth = 2
  109.  
  110.  
  111. ------------------------------------------------------------------------
  112. -- Key bindings
  113. --
  114. -- modMask lets you specify which modkey you want to use. The default
  115. -- is mod1Mask ("left alt"). You may also consider using mod3Mask
  116. -- ("right alt"), which does not conflict with emacs keybindings. The
  117. -- "windows key" is usually mod4Mask.
  118. --
  119. myModMask = mod1Mask
  120.  
  121. myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  122. ----------------------------------------------------------------------
  123. -- Custom key bindings
  124. --
  125.  
  126. -- Start a terminal. Terminal to start is specified by myTerminal variable.
  127. [ ((modMask .|. shiftMask, xK_Return),
  128. spawn $ XMonad.terminal conf)
  129.  
  130. -- Takes screenshot
  131. , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s -e 'mv $f ~dana/Pictures/Screenshots'")
  132. , ((0, xK_Print), spawn "scrot -e 'mv $f ~dana/Pictures/Screenshots'")
  133.  
  134.  
  135. , ((modMask, xK_p),
  136. spawn "exe=`dmenu_path_c | yeganesh` && eval \"exec $exe\"")
  137.  
  138. -- Mute volume.
  139. , ((modMask .|. controlMask, xK_m),
  140. spawn "amixer -q set Master toggle")
  141.  
  142. -- Decrease volume.
  143. , ((modMask .|. controlMask, xK_j),
  144. spawn "amixer -q set Master 5%-")
  145.  
  146. -- Increase volume.
  147. , ((modMask .|. controlMask, xK_k),
  148. spawn "amixer -q set Master 5%+")
  149.  
  150. -- Audio previous.
  151. , ((0, 0x1008FF16),
  152. spawn "")
  153.  
  154. -- Play/pause.
  155. , ((0, 0x1008FF14),
  156. spawn "")
  157.  
  158. -- Audio next.
  159. , ((0, 0x1008FF17),
  160. spawn "")
  161.  
  162. -- Eject CD tray.
  163. , ((0, 0x1008FF2C),
  164. spawn "eject -T")
  165.  
  166. --------------------------------------------------------------------
  167. -- "Standard" xmonad key bindings
  168. --
  169.  
  170. -- Close focused window.
  171. , ((modMask .|. shiftMask, xK_c),
  172. kill)
  173.  
  174. -- Cycle through the available layout algorithms.
  175. , ((modMask, xK_space),
  176. sendMessage NextLayout)
  177.  
  178. -- Reset the layouts on the current workspace to default.
  179. , ((modMask .|. shiftMask, xK_space),
  180. setLayout $ XMonad.layoutHook conf)
  181.  
  182. -- Resize viewed windows to the correct size.
  183. , ((modMask, xK_n),
  184. refresh)
  185.  
  186. -- Move focus to the next window.
  187. , ((modMask, xK_Tab),
  188. windows W.focusDown)
  189.  
  190. -- Move focus to the next window.
  191. , ((modMask, xK_j),
  192. windows W.focusDown)
  193.  
  194. -- Move focus to the previous window.
  195. , ((modMask, xK_k),
  196. windows W.focusUp )
  197.  
  198. -- Move focus to the master window.
  199. , ((modMask, xK_m),
  200. windows W.focusMaster )
  201.  
  202. -- Swap the focused window and the master window.
  203. , ((modMask, xK_Return),
  204. windows W.swapMaster)
  205.  
  206. -- Swap the focused window with the next window.
  207. , ((modMask .|. shiftMask, xK_j),
  208. windows W.swapDown )
  209.  
  210. -- Swap the focused window with the previous window.
  211. , ((modMask .|. shiftMask, xK_k),
  212. windows W.swapUp )
  213.  
  214. -- Shrink the master area.
  215. , ((modMask, xK_h),
  216. sendMessage Shrink)
  217.  
  218. -- Expand the master area.
  219. , ((modMask, xK_l),
  220. sendMessage Expand)
  221.  
  222. -- Push window back into tiling.
  223. , ((modMask, xK_t),
  224. withFocused $ windows . W.sink)
  225.  
  226. -- Increment the number of windows in the master area.
  227. , ((modMask, xK_comma),
  228. sendMessage (IncMasterN 1))
  229.  
  230. -- Decrement the number of windows in the master area.
  231. , ((modMask, xK_period),
  232. sendMessage (IncMasterN (-1)))
  233.  
  234. -- Toggle the status bar gap.
  235. -- TODO: update this binding with avoidStruts, ((modMask, xK_b),
  236.  
  237. -- Quit xmonad.
  238. , ((modMask .|. shiftMask, xK_q),
  239. io (exitWith ExitSuccess))
  240.  
  241. -- Restart xmonad.
  242. , ((modMask, xK_q),
  243. restart "xmonad" True)
  244. ]
  245. ++
  246.  
  247. -- mod-[1..9], Switch to workspace N
  248. -- mod-shift-[1..9], Move client to workspace N
  249. [((m .|. modMask, k), windows $ f i)
  250. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  251. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  252. ++
  253.  
  254. -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  255. -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  256. [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  257. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  258. , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  259.  
  260.  
  261. ------------------------------------------------------------------------
  262. -- Mouse bindings
  263. --
  264. -- Focus rules
  265. -- True if your focus should follow your mouse cursor.
  266. myFocusFollowsMouse :: Bool
  267. myFocusFollowsMouse = False
  268.  
  269. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  270. [
  271. -- mod-button1, Set the window to floating mode and move by dragging
  272. ((modMask, button1),
  273. (\w -> focus w >> mouseMoveWindow w))
  274.  
  275. -- mod-button2, Raise the window to the top of the stack
  276. , ((modMask, button2),
  277. (\w -> focus w >> windows W.swapMaster))
  278.  
  279. -- mod-button3, Set the window to floating mode and resize by dragging
  280. , ((modMask, button3),
  281. (\w -> focus w >> mouseResizeWindow w))
  282.  
  283. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  284. ]
  285.  
  286. ------------------------------------------------------------------------
  287. -- Startup hook
  288. -- Perform an arbitrary action each time xmonad starts or is restarted
  289. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  290. -- per-workspace layout choices.
  291. --
  292. -- By default, do nothing.
  293. myStartupHook = return ()
  294.  
  295. ------------------------------------------------------------------------
  296. -- Floats all windows in a certain workspace.
  297. -- myLayouts
  298. myLayouts = onWorkspace "three" simplestFloat $ defaultLayouts
  299.  
  300. ------------------------------------------------------------------------
  301. -- Run xmonad with all the defaults we set up.
  302. --
  303. --main = xmonad =<< xmobar defaultConfig { terminal = "urxvt" }
  304.  
  305. main = do
  306. xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmobarrc"
  307. xmonad $ defaults
  308. { manageHook = manageDocks <+> manageHook defaultConfig
  309. , layoutHook = avoidStruts $ myLayouts
  310. , startupHook = setWMName "LG3D"
  311. , logHook = dynamicLogWithPP xmobarPP
  312. { ppOutput = hPutStrLn xmproc
  313. , ppTitle = xmobarColor "#657b83" "" . shorten 100
  314. , ppCurrent = xmobarColor "#c0c0c0" "" . wrap "" ""
  315. , ppSep = xmobarColor "#c0c0c0" "" " | "
  316. , ppUrgent = xmobarColor "#ff69b4" ""
  317. , ppLayout = const "" -- to disable the layout info on xmobar
  318. }
  319. }
  320.  
  321.  
  322. ------------------------------------------------------------------------
  323. -- Combine it all together
  324. -- A structure containing your configuration settings, overriding
  325. -- fields in the default config. Any you don't override, will
  326. -- use the defaults defined in xmonad/XMonad/Config.hs
  327. --
  328. -- No need to modify this.
  329. --
  330. defaults = defaultConfig {
  331. -- simple stuff
  332. terminal = myTerminal,
  333. focusFollowsMouse = myFocusFollowsMouse,
  334. borderWidth = myBorderWidth,
  335. modMask = myModMask,
  336. workspaces = myWorkspaces,
  337. normalBorderColor = myNormalBorderColor,
  338. focusedBorderColor = myFocusedBorderColor,
  339.  
  340. -- key bindings
  341. keys = myKeys,
  342. mouseBindings = myMouseBindings,
  343.  
  344. -- hooks, layouts
  345. -- defaultLayouts = smartBorders $ myLayout,
  346. -- layoutHook = myLayouts,
  347. manageHook = myManageHook,
  348. startupHook = myStartupHook
  349. }
Advertisement
Add Comment
Please, Sign In to add comment