Advertisement
Guest User

Untitled

a guest
May 31st, 2012
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.85 KB | None | 0 0
  1. -- example config file.
  2. --
  3. -- A template showing all available configuration hooks,
  4. -- and how to override the defaults in your own xmonad.hs conf file.
  5. --
  6. -- Normally, you'd only override those defaults you care about.
  7. --
  8.  
  9. import XMonad hiding ( (|||) )
  10. import Data.Monoid
  11. import System.Exit
  12. import qualified XMonad.StackSet as W
  13. import qualified Data.Map as M
  14.  
  15. -- хуки
  16. import XMonad.Hooks.DynamicLog
  17. import XMonad.Hooks.ManageDocks
  18. import XMonad.Hooks.DynamicLog (PP(..), dynamicLogWithPP, wrap, defaultPP, xmobarPP, xmobarColor, xmobarStrip)
  19. import XMonad.Hooks.UrgencyHook
  20. import XMonad.Hooks.EwmhDesktops
  21. import XMonad.Hooks.ManageHelpers
  22. import XMonad.Hooks.InsertPosition
  23.  
  24. -- экшены
  25. import XMonad.Actions.CopyWindow
  26. import XMonad.Actions.CycleWS
  27. import XMonad.Actions.NoBorders
  28. import XMonad.Actions.Submap
  29. import XMonad.Actions.Search
  30. import XMonad.Actions.WindowBringer (bringWindow)
  31. import XMonad.Actions.OnScreen -- Несколько экранов
  32. --import XMonad.Actions.UpdatePointer
  33.  
  34. -- слои
  35. import XMonad.Layout.LayoutCombinators
  36. import XMonad.Layout.Dishes
  37. import XMonad.Layout.Grid
  38. import XMonad.Layout.NoBorders
  39. import XMonad.Layout.ThreeColumns
  40. import XMonad.Layout.ResizableTile
  41. import XMonad.Layout.PerWorkspace
  42.  
  43. import XMonad.Prompt
  44. import XMonad.Prompt.AppLauncher as AL
  45. import XMonad.Prompt.AppendFile
  46. import XMonad.Prompt.Input
  47. import XMonad.Prompt.Man
  48. import XMonad.Prompt.Shell
  49. import XMonad.Prompt.Ssh
  50. import XMonad.Prompt.Theme
  51. import XMonad.Prompt.Window
  52. import XMonad.Prompt.Workspace
  53. import XMonad.Prompt.XMonad
  54. import XMonad.Util.Run (spawnPipe)
  55. import XMonad.Util.EZConfig
  56.  
  57. import Control.OldException
  58. import Control.Monad
  59. import Control.Concurrent
  60. import System.IO
  61. import System.Exit
  62. import System.Environment
  63. import System.Cmd
  64. import Text.Printf
  65.  
  66. import qualified XMonad.StackSet as W
  67. import qualified Data.Map as M
  68.  
  69. -- Терминал
  70. myTerminal = "urxvtcd"
  71.  
  72. -- Передавать ли фокус окну, при наведении мыши
  73. myFocusFollowsMouse :: Bool
  74. myFocusFollowsMouse = False
  75.  
  76. -- Ширина рамки окна в пикселях
  77. myBorderWidth = 2
  78.  
  79. -- задаем modkey. mod1Mask (левый alt), mod3Mask (правый альт), mod4Mask (super)
  80. myModMask = mod1Mask
  81.  
  82. -- Воркспэйсы (виртуальыне рабочие столы)
  83. myWorkspaces = ["1:term","2:dev","3:www","4:xmpp","5:info","6:gimp","7:game","8","9"]
  84.  
  85. -- Цвет рамки обычного (normal) и активного (focused) окна
  86. myNormalBorderColor = "#3f3f3f"
  87. myFocusedBorderColor = "#BD3E3E"
  88.  
  89. -- Кейбиндинги. Тут создаются и изменяются горячие клавиши
  90. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  91.  
  92. -- Запустить терминал
  93. [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  94.  
  95. -- Запустить dmenu
  96. , ((modm, xK_p ), spawn "exe=`dmenu_path | dmenu -nb \"#3f3f3f\" -nf \"#adadad\" -sb \"#5ca84f\" -sf \"#3f3f3f\"` && eval $exe")
  97.  
  98. -- Запустить gmrun
  99. , ((modm .|. shiftMask, xK_p ), spawn "gmrun")
  100.  
  101. -- Запустить iceweasel
  102. , ((modm .|. shiftMask, xK_i ), spawn "iceweasel")
  103.  
  104. -- Залочить экран
  105. , ((modm .|. shiftMask, xK_l ), spawn "xscreensaver-command -lock")
  106.  
  107. -- Закрыть окно с фокусом
  108. , ((modm .|. shiftMask, xK_c ), kill)
  109.  
  110. -- Сменить тип слоя
  111. , ((modm, xK_space ), sendMessage NextLayout)
  112.  
  113. -- Востоновить тип слоя для воркспейса по дефолту
  114. , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  115.  
  116. -- Resize viewed windows to the correct size
  117. , ((modm, xK_n ), refresh)
  118.  
  119. -- Move focus to the next window
  120. , ((modm, xK_Tab ), windows W.focusDown)
  121.  
  122. -- Move focus to the next window
  123. , ((modm, xK_j ), windows W.focusDown)
  124.  
  125. -- Move focus to the previous window
  126. , ((modm, xK_k ), windows W.focusUp )
  127.  
  128. -- Move focus to the master window
  129. , ((modm, xK_m ), windows W.focusMaster )
  130.  
  131. -- Swap the focused window and the master window
  132. , ((modm, xK_Return), windows W.swapMaster)
  133.  
  134. -- Swap the focused window with the next window
  135. , ((modm .|. shiftMask, xK_j ), windows W.swapDown )
  136.  
  137. -- Swap the focused window with the previous window
  138. , ((modm .|. shiftMask, xK_k ), windows W.swapUp )
  139.  
  140. -- Shrink the master area
  141. , ((modm, xK_h ), sendMessage Shrink)
  142.  
  143. -- Expand the master area
  144. , ((modm, xK_l ), sendMessage Expand)
  145.  
  146. -- Push window back into tiling
  147. , ((modm, xK_t ), withFocused $ windows . W.sink)
  148.  
  149. -- Increment the number of windows in the master area
  150. , ((modm , xK_comma ), sendMessage (IncMasterN 1))
  151.  
  152. -- Deincrement the number of windows in the master area
  153. , ((modm , xK_period), sendMessage (IncMasterN (-1)))
  154.  
  155. -- Toggle the status bar gap
  156. -- Use this binding with avoidStruts from Hooks.ManageDocks.
  157. -- See also the statusBar function from Hooks.DynamicLog.
  158. --
  159. , ((modm , xK_b ), sendMessage ToggleStruts)
  160.  
  161. -- Quit xmonad
  162. , ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  163. -- Ресайз
  164. , ((modm, xK_a), sendMessage MirrorShrink)
  165. , ((modm, xK_z), sendMessage MirrorExpand)
  166. , ((modm, xK_Print), spawn "scrot")
  167. , ((modm .|. shiftMask, xK_Print), spawn "scrot -u")
  168. -- Restart xmonad
  169. , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
  170. -- XF86AudioLowerVolume
  171. , ((0 , 0x1008ff11), spawn "amixer -q set Master 2dB-")
  172. -- XF86AudioRaiseVolume
  173. , ((0 , 0x1008ff13), spawn "amixer -q set Master 2dB+")
  174. -- XF86AudioMute
  175. , ((0 , 0x1008ff12), spawn "amixer -q set Master toggle")
  176. ]
  177. ++
  178.  
  179. --
  180. -- mod-[1..9], Switch to workspace N
  181. --
  182. -- mod-[1..9], Switch to workspace N
  183. -- mod-shift-[1..9], Move client to workspace N
  184. --
  185. [((m .|. modm, k), windows $ f i)
  186. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  187. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  188. ++
  189.  
  190. --
  191. -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  192. -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  193. --
  194. [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  195. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  196. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  197.  
  198. ++
  199. [ ((m .|. modm, k), windows (f i))
  200. | (i, k) <- zip (workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
  201. , (f, m) <- [ (viewOnScreen 1, 0)
  202. , (viewOnScreen 0, controlMask)
  203. , (W.greedyView, controlMask .|. shiftMask) ]
  204. ]
  205.  
  206.  
  207. ------------------------------------------------------------------------
  208. -- Mouse bindings: default actions bound to mouse events
  209. --
  210. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  211.  
  212. -- mod-button1, Set the window to floating mode and move by dragging
  213. [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  214. >> windows W.shiftMaster))
  215.  
  216. -- mod-button2, Raise the window to the top of the stack
  217. , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  218.  
  219. -- mod-button3, Set the window to floating mode and resize by dragging
  220. , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  221. >> windows W.shiftMaster))
  222.  
  223. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  224. ]
  225.  
  226. ------------------------------------------------------------------------
  227. -- Layouts:
  228.  
  229. -- You can specify and transform your layouts by modifying these values.
  230. -- If you change layout bindings be sure to use 'mod-shift-space' after
  231. -- restarting (with 'mod-q') to reset your layout state to the new
  232. -- defaults, as xmonad preserves your old layout settings by default.
  233. --
  234. -- * NOTE: XMonad.Hooks.EwmhDesktops users must remove the obsolete
  235. -- ewmhDesktopsLayout modifier from layoutHook. It no longer exists.
  236. -- Instead use the 'ewmh' function from that module to modify your
  237. -- defaultConfig as a whole. (See also logHook, handleEventHook, and
  238. -- startupHook ewmh notes.)
  239. --
  240. -- The available layouts. Note that each layout is separated by |||,
  241. -- which denotes layout choice.
  242. --
  243. myLayout =
  244. onWorkspace "3:www" (Mirror wwwtiled) $
  245. onWorkspace "4:xmpp" (Grid ||| tiled ||| Mirror tiled) $
  246. (tiled ||| Mirror tiled ||| ThreeCol 1 (3/100) (1/2) ||| Grid ||| noBorders Full ||| Dishes 2 (1/6))
  247. where
  248. tiled = ResizableTall 1 (3/100) (1/2) []
  249. wwwtiled = ResizableTall 2 (3/100) (5/6) []
  250. ------------------------------------------------------------------------
  251. -- Window rules:
  252.  
  253. -- Execute arbitrary actions and WindowSet manipulations when managing
  254. -- a new window. You can use this to, for example, always float a
  255. -- particular program, or have a client always appear on a particular
  256. -- workspace.
  257. --
  258. -- To find the property name associated with a program, use
  259. -- > xprop | grep WM_CLASS
  260. -- and click on the client you're interested in.
  261. --
  262. -- To match on the WM_NAME, you can use 'title' in the same way that
  263. -- 'className' and 'resource' are used below.
  264. --
  265. myManageHook = composeAll
  266. [ className =? "Gimp" --> (doFloat <+> doF (W.shift "6:gimp") <+> insertPosition Master Newer)
  267. , className =? "feh" --> doCenterFloat
  268. , className =? "soffice" --> doCenterFloat <+> insertPosition Master Newer
  269. , className =? "Xmessage" --> doCenterFloat
  270. , className =? "Gmessage" --> doCenterFloat
  271. , className =? "Gmrun" --> doCenterFloat
  272. , className =? "Wine" --> doCenterFloat
  273. , className =? "Iceweasel" --> doF (W.shift "3:www")
  274. , isDialog --> doCenterFloat <+> insertPosition Master Newer
  275. , isFullscreen --> doFloat <+> insertPosition Master Newer
  276. , title =? "Настройки Iceweasel" --> doCenterFloat
  277. -- , title =? "Scanning network from localhost" --> doCenterFloat
  278. , title =? "ncmpcpp" --> doF (W.shift "4:xmpp")
  279. , title =? "newsbeuter" --> doF (W.shift "4:xmpp")
  280. , title =? "mcabber" --> doF (W.shift "4:xmpp")
  281. , title =? "mutt" --> doF (W.shift "4:xmpp")
  282. , title =? "termto4ws" --> doF (W.shift "4:xmpp")
  283. , resource =? "desktop_window" --> doIgnore
  284. , resource =? "kdesktop" --> doIgnore
  285. , insertPosition Below Newer
  286. ]
  287.  
  288. ------------------------------------------------------------------------
  289. -- Event handling
  290.  
  291. -- Defines a custom handler function for X Events. The function should
  292. -- return (All True) if the default handler is to be run afterwards. To
  293. -- combine event hooks use mappend or mconcat from Data.Monoid.
  294. --
  295. -- * NOTE: EwmhDesktops users should use the 'ewmh' function from
  296. -- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
  297. -- It will add EWMH event handling to your custom event hooks by
  298. -- combining them with ewmhDesktopsEventHook.
  299. --
  300. myEventHook = mempty
  301.  
  302. ------------------------------------------------------------------------
  303. -- Status bars and logging
  304.  
  305. -- Perform an arbitrary action on each internal state change or X event.
  306. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  307. --
  308. -- * NOTE: EwmhDesktops users should use the 'ewmh' function from
  309. -- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
  310. -- It will add EWMH logHook actions to your custom log hook by
  311. -- combining it with ewmhDesktopsLogHook.
  312. --
  313. --myLogHook = dynamicLogWithPP xmobarPP
  314.  
  315. myLogHook = dynamicLogWithPP xmobarPP
  316. { --- ppOutput = hPutStrLn
  317. ppTitle = xmobarColor "#3F3F3F" "" . shorten 0
  318. ,ppCurrent = xmobarColor "#3F3F3F" "#5AB75A" . pad
  319. ,ppUrgent = xmobarColor "#3F3F3F" "#5AB75A"
  320. }
  321.  
  322. --------r---------------------------------------------------------------
  323. -- Startup hook
  324. -- Perform an arbitrary action each time xmonad starts or is restarted
  325. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  326. -- per-workspace layout choices.
  327. --
  328. -- By default, do nothing.
  329. --
  330. -- * NOTE: EwmhDesktops users should use the 'ewmh' function from
  331. -- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
  332. -- It will add initialization of EWMH support to your custom startup
  333. -- hook by combining it with ewmhDesktopsStartup.
  334. --
  335. myStartupHook = return ()
  336.  
  337. ------------------------------------------------------------------------
  338. -- Now run xmonad with all the defaults we set up.
  339.  
  340. -- Run xmonad with the settings you specify. No need to modify this.
  341. --
  342. main = do
  343. xmonad $ defaultConfig {
  344. -- simple stuff
  345. terminal = myTerminal,
  346. focusFollowsMouse = myFocusFollowsMouse,
  347. borderWidth = myBorderWidth,
  348. modMask = myModMask,
  349. workspaces = myWorkspaces,
  350. normalBorderColor = myNormalBorderColor,
  351. focusedBorderColor = myFocusedBorderColor,
  352.  
  353. -- key bindings
  354. keys = myKeys,
  355. mouseBindings = myMouseBindings,
  356.  
  357. -- hooks, layouts
  358. layoutHook = avoidStruts myLayout,
  359. manageHook = myManageHook <+> manageDocks,
  360. handleEventHook = myEventHook,
  361. logHook = myLogHook,
  362. startupHook = myStartupHook
  363. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement