Guest User

Untitled

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