Guest User

Untitled

a guest
Dec 11th, 2011
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [code]
  2. {-# LANGUAGE NoMonomorphismRestriction #-}
  3. -------------------------------------------------------
  4. import XMonad  hiding ( (|||) )
  5. import qualified XMonad.StackSet as W -- Keys
  6. import qualified Data.Map as M        -- Keys
  7. -------------------------------------------------------
  8. --import Text.Regex.Posix
  9. import Data.List
  10. import Data.Monoid
  11. import Data.Ratio ((%))
  12. import System.IO
  13. import Control.Applicative ((<$>))
  14. import Control.Arrow ((&&&))
  15. ------------------------------------------------------------------
  16. import XMonad.Hooks.DynamicLog        -- Xmobar
  17. import XMonad.Hooks.UrgencyHook       -- Urgent
  18. import XMonad.Hooks.DynamicHooks
  19. import XMonad.Hooks.ManageHelpers     -- Helper functions
  20. import XMonad.Hooks.ManageDocks       -- App workspace
  21. import XMonad.Hooks.EwmhDesktops
  22. import XMonad.Hooks.FadeInactive(setOpacity)
  23. import XMonad.Hooks.SetWMName         -- Java GUI programs in non-reparenting WMs
  24. import XMonad.Hooks.XPropManage
  25.  
  26. import XMonad.Layout.MultiToggle.Instances
  27. import XMonad.Layout.LayoutScreens
  28. import XMonad.Layout.ResizableTile    -- Rezise
  29. import XMonad.Layout.Tabbed           -- Tab
  30. import XMonad.Layout.Named            -- Named
  31. import XMonad.Layout.SubLayouts       -- Sub layouts
  32. import XMonad.Layout.Simplest         -- Simple Layout
  33. import XMonad.Layout.SimplestFloat
  34. import XMonad.Layout.WindowNavigation -- Windows navigator
  35. import XMonad.Layout.Spacing
  36. import XMonad.Layout.Reflect
  37. import XMonad.Layout.ComboP
  38. import XMonad.Layout.TwoPane
  39. import XMonad.Layout.LayoutCombinators
  40. import XMonad.Layout.PerWorkspace
  41. import XMonad.Layout.LayoutBuilderP
  42. import XMonad.Layout.TrackFloating
  43. import qualified XMonad.Layout.WindowNavigation as Nav
  44. import XMonad.Layout.TrackFloating
  45. --import XMonad.Layout.MagicFocus
  46. -----------------------------------------------------------------
  47. import XMonad.Actions.CopyWindow      -- Copy window to workspace
  48. import XMonad.Actions.WindowGo        -- RunOrRaise, etc
  49. import XMonad.Actions.Commands
  50. import XMonad.Actions.UpdatePointer
  51. import XMonad.Actions.UpdateFocus
  52. import XMonad.Actions.TagWindows
  53. import XMonad.Actions.Submap
  54. import XMonad.Actions.DwmPromote
  55. -----------------------------------------------------------------
  56. import XMonad.Prompt
  57. -----------------------------------------------------------------
  58. import XMonad.Util.Run hiding (hPutStrLn)
  59. import XMonad.Util.WindowProperties
  60. import XMonad.Util.NamedScratchpad 
  61. import XMonad.Util.NamedActions
  62. import XMonad.Util.EZConfig
  63. --import XMonad.Util.Stack
  64.  
  65. import XMonad.Layout.WindowArranger
  66. import XMonad.Util.WindowPropertiesRE
  67.  
  68. import XMonad.Layout.Groups
  69. import XMonad.Layout.Groups.Wmii
  70. import XMonad.Layout.Groups.Examples
  71.  
  72.  
  73. import XMonad.Layout.NoFrillsDecoration
  74. --import qualified XMonad.Layout.TabbedModifier as Tab
  75.  
  76. import App
  77. import BorderColors
  78. import MyApps
  79. import Utils
  80. import Workspace
  81. -----------------------------------------------------------------
  82. --q ~? x = fmap (=~ x) q
  83. chooseLayout name = sendMessage $ JumpToLayout name
  84. spawnMany lst = foldr1 (>>) (map spawn lst)
  85. --myPlacement = withGaps (22, 0, 0, 0) $ smart (0.5,0.5)
  86.  
  87. fromX :: X () -> ManageHook
  88. fromX op = fromWindowOp $ const op
  89.  
  90. fromWindowOp :: (Window -> X()) -> ManageHook
  91. fromWindowOp fn = ask >>= \w -> liftX (fn w) >> doF id
  92.  
  93. -- Avoid changing master on new window creation
  94. avoidMaster :: W.StackSet i l a s sd -> W.StackSet i l a s sd
  95. avoidMaster = W.modify' $ \c -> case c of
  96.     W.Stack t [] (r:rs) -> W.Stack t [r] rs
  97.     otherwise           -> c
  98. -----------------------------------------------------------------
  99. showtag name    = withTaggedGlobalP name shiftHere
  100. -- вкл/выкл тег name для текущего окна
  101. toggletag name  = withFocused $ \w -> hasTag name w >>=
  102.                (\b -> if b then delTag name w else addTag name w)
  103. -- снять тег name
  104. remtag name     = withFocused (delTag name)
  105. -- перейти к следующему окну, помеченному тегом name
  106. nexttagged name = focusDownTaggedGlobal name
  107. -- переместить окна с тегом name с текущего workspace на "T"
  108. shiftoff name   = withTaggedP name (W.shiftWin "T")
  109.  
  110. --copyWin = ask >>= \w -> doF (\ws -> copyWindow w (W.currentTag ws) ws)
  111. --copyWins' = ask >>= doF .  \w -> (copyWindow w "2:web")
  112.  
  113. -- Объявить сочетания клавиш для тега tag с клавишей tag
  114. tagkeys mask key tag = [
  115.      ((mod1Mask, key),  showtag tag)
  116.     ,((mod4Mask, key),  toggletag tag)
  117.     ,((mod3Mask, key),  nexttagged tag)
  118.     ,((mod4Mask .|. controlMask, key), shiftoff tag)
  119.     ]
  120. -----------------------------------------------------------------
  121. addKeys = [
  122.      "M-l"           ~>  sendMessage $ Go R
  123.    , "M-h"           ~>  sendMessage $ Go L
  124.    , "M-k"           ~>  sendMessage $ Go U
  125.    , "M-j"           ~>  sendMessage $ Go D
  126.  
  127. -- ,"`"              ~>  dwmpromote
  128. -- ,"<KP_Enter>"     ~>  withFocused $ windows . W.sink
  129.  
  130.    , "M-u"           ~> swapOrRaise
  131.    , "M-S-u"         ~> swapOrLower
  132.  
  133.    , "M1-C-l"        ~>  hideSummonWindows apps
  134.  
  135. -- , "M-<Home>"      ~>  spawn "vim ~/.xmonad/xmonad.hs"
  136. -- , "M-<Home>"      ~>  spawn "gvim ~/.xmonad/xmonad.hs"
  137.    , "M-w"           ~>  runOrRaiseNext "firefox"  (className =? "Firefox")
  138.    , "M-S-p"         ~>  runOrRaiseNext "ktorrent" (className =? "Ktorrent")
  139. -- , "M-w"           ~>  runOrRaiseNext "conkeror" (className =? "Conkeror")
  140. -- , "M-e"           ~>  runOrRaiseNext "kopete"  (className =? "Kopete")
  141. -- , "M-C-e"         ~>  runOrCopy      "kopete"  (className =? "Kopete")
  142. -- , "M-e"           ~>  ifWindow (matchclass "Kopete") copyWin (spawn "kopete")
  143.    , "M-o"           ~>  runOrRaiseNext "okular"  (className =? "Okular")
  144.    , "M-x"           ~>  runOrRaise "/home/neg/bin/urxvt" (resource =? "MainTerminal")
  145.  
  146.    , "M-<Home>"      ~>  namedScratchpadAction scratchpads "XmndConf"
  147.    , "M-e"           ~>  namedScratchpadAction scratchpads "finch"
  148.    , "M-r"           ~>  namedScratchpadAction scratchpads "weechat"
  149.    , "M-s"           ~>  namedScratchpadAction scratchpads "music"
  150.    , "M-p"           ~>  namedScratchpadAction scratchpads "torrent"
  151.    , "M-b"           ~>  namedScratchpadAction scratchpads "alsamixer"
  152.  
  153.    , "M4-<Space>"    ~>  showtag "scratchpad"
  154.    
  155.    , "M4-f"          ~>  onGroup W.focusUp'  
  156.   , "M4-v"          ~>  onGroup W.focusDown'
  157.  
  158.    , "M-C-t"         ~>  withFocused $ windows . W.sink
  159.    , "M-<F1>"        ~>  sendMessage (IncMasterN 1)
  160.    , "M-<F2>"        ~>  sendMessage (IncMasterN (-1))
  161. -- Sub Layout ------------------------------------------------------------
  162.    , "M-C-h"         ~>  sendMessage $ pullGroup L
  163.    , "M-C-l"         ~>  sendMessage $ pullGroup R
  164.    , "M-C-k"         ~>  sendMessage $ pullGroup U
  165.    , "M-C-j"         ~>  sendMessage $ pullGroup D
  166.                      
  167.    , "M-C-m"         ~>  withFocused (sendMessage . MergeAll)
  168.    , "M-C-u"         ~>  withFocused (sendMessage . UnMerge)
  169.    , "M-n"           ~>  refresh
  170.    , "M-<Return>"    ~>  windows W.swapMaster
  171.                      
  172.    , "M-<L>"         ~>  sendMessage Shrink
  173.    , "M-<R>"         ~>  sendMessage Expand
  174.    , "M-<D>"         ~>  sendMessage MirrorShrink
  175.    , "M-<U>"         ~>  sendMessage MirrorExpand
  176.    , "M-S-<R>"       ~>  sendMessage $ Swap R
  177.    , "M-S-<L>"       ~>  sendMessage $ Swap L
  178.    , "M-S-<U>"       ~>  sendMessage $ Swap U
  179.    , "M-S-<D>"       ~>  sendMessage $ Swap D
  180.  
  181.    , "M--"           ~> zoomWindowOut
  182.                      
  183.    , "M-/" ~>  spawn "gmrun"
  184.    , "M-S-e"         ~>  spawn "sudo eject"
  185.    , "M-C-q"           ~>  kill1 -- @@ Close the focused window
  186. -- , "M-S-r"         ~>  spawn "xmonad --recompile; xmonad --restart"
  187.    , "M-S-r"         ~>  spawn "pkill xmobar; xmonad --recompile; xmonad --restart"
  188.    , "M-C-i"         ~>  spawn "env GTK2_RC_FILES=$HOME/.themes/Clearlooks-DarkBlue/gtk-2.0/gtkrc inkscape"
  189.    , "M-C-o"         ~>  spawn "libreoffice"
  190.    , "M-C-g"         ~>  spawn "gimp"
  191.    , "M-C-a"         ~>  spawn "$HOME/bin/virt.sh"
  192.    , "M-<Print>"     ~>  spawn "scrot screen_%Y-%m-%d.png -d 1"  -- take screenshot
  193. -- Mpd -----------------------------------------------------------------
  194.    , "<XF86AudioPlay>" ~>  spawn "mpc toggle"
  195.    , "<XF86AudioNext>" ~>  spawn "mpc next"
  196.    , "<XF86AudioPrev>" ~>  spawn "mpc prev"
  197.  
  198.    , "M1-C-z"          ~>  spawn "mpc volume -5"
  199.    , "M1-C-x"          ~>  spawn "mpc volume +5"
  200. -- Volume --------------------------------------------------------------
  201.    , "<XF86AudioRaiseVolume>"
  202.                        ~> spawn "amixer sset Master 5%+"
  203.    , "<XF86AudioLowerVolume>"
  204.                        ~> spawn "amixer sset Master 5%-"
  205.    , "<Print>"         ~> spawn "ksnapshot"
  206.  
  207.       -- Rotate windows list
  208.    , "M4-C-n"           ~> rotateWindows'
  209.   , "M4-M1-C-U"        ~> spawn "sudo /usr/sbin/hibernate-ram"
  210.   -- Пометить текущее окно произвольным тегом
  211. -- , "M1-/"  ~> tagPrompt defaultXPConfig (\s -> withFocused (addTag s))
  212.   -- Снять произвольный тег
  213.   , "M-S-/" ~> tagDelPrompt defaultXPConfig
  214.   -- Переместить окна, помеченные произвольным тегом, на текущий workspace
  215. -- , "M1-w"  ~> tagPrompt defaultXPConfig (\s -> withTaggedGlobalP s shiftHere)
  216.   ]
  217.     where
  218.     focusAnd job1 job2 w = focus w >> windows W.swapMaster >> job1 w >> job2 w
  219. -- W.RationalRect x-gap y-gap width height
  220. hideScratchpad ws = if ws == "NSP" then "" else pad ws
  221. scratchpads =
  222.    [  
  223.      NS "scratchpad" spawnScratchpad    findScratchpad (customFloating$rr 0.42 0.08 0.50 0.33)
  224.    , NS "stardict"   "stardict"         findDict       (customFloating$rr 0.50 0.00 0.25 1.00)
  225.    , NS "mutt"       spawnMutt          findMutt       (customFloating$rr 0.26 0.30 0.66 0.66)
  226.    , NS "finch"      spawnFinch         findFinch      (customFloating$rr 0.26 0.30 0.66 0.66)
  227.    , NS "weechat"    spawnWeechat       findWeechat    (customFloating$rr 0.26 0.30 0.66 0.66)
  228.    , NS "XmndConf"   spawnXmndConf      findXmndConf   (customFloating$rr 0.26 0.30 0.66 0.66)
  229.    , NS "torrent"    "ktorrent"         findTorrent    (customFloating$rr 0.24 0.24 0.66 0.66)
  230.    , NS "alsamixer"  spawnMixer         findMixer      (customFloating$rr 0.42 0.08 0.50 0.33)
  231.    , NS "music"      spawnMusic         findMusic      (customFloating$rr 0.42 0.08 0.50 0.33)
  232.    ]
  233.    where
  234.      role = stringProperty "WM_WINDOW_ROLE"
  235.      rr   = W.RationalRect
  236.      findMixer        = resource =? "Alsamixer"
  237.      findMutt         = resource =? "mutt"
  238.      findScratchpad   = resource =? "scratchpad"
  239.      findDict         = className =? "Stardict"
  240.      findTorrent      = className =? "Ktorrent"
  241.      findMusic        = resource  =? "mpd_music"
  242.      findWeechat      = resource  =? "uWeechat"
  243.      findFinch        = resource  =? "uFinch"
  244.      findXmndConf     = resource  =? "XmonadConfig"
  245.        
  246.      spawnMixer       = "urxvt -fn xft:snap -name Alsamixer -e alsamixer"
  247.      spawnScratchpad  = "urxvt -fn \"xft:terminus:pixelsize=14\" -name scratchpad"
  248.      spawnMusic       = "urxvt -fn \"xft:terminus:pixelsize=14\" -name  mpd_music -e ncmpcpp"
  249.      spawnMutt     = "urxvt -fn -fontforge-proggyopticyr-medium-r-normal--11-80-96-96-p-70-iso10646-1 -name uMutt -e mutt"
  250.      spawnXmndConf    = "urxvt -fn \"xft:terminus:pixelsize=14\" -name XmonadConfig -e vim ~/.xmonad/xmonad.hs"
  251.      spawnWeechat     = "urxvt -fn \"xft:terminus:pixelsize=14\" -name uWeechat -e weechat-curses"
  252.      spawnFinch       = "urxvt -fn \"xft:terminus:pixelsize=14\" -name uFinch -e finch"
  253.  
  254. dzenFont        = "-hell-monobook-bold-r-normal--24-240-72-72-m-120-iso10646-1"
  255. myFont          = "-misc-fixed-medium-r-semicondensed-*-12-110-75-75-c-60-koi8-r"
  256.  
  257. myIconDir       = "/home/neg/.dzen"
  258.  
  259. myDzenFGColor        = "#555555"
  260. myDzenBGColor        = "#000000"
  261. myNormalFGColor      = "#ffffff"
  262. myNormalBGColor      = "#000000"
  263. myNormalBorderColor  = "#202020"
  264. myFocusedBorderColor = "#404040"
  265. myFocusedFGColor     = "#f0f0f0"
  266. myFocusedBGColor     = "#8536C9"
  267. myUrgentFGColor      = "#0099ff"
  268. myUrgentBGColor      = "#0077ff"
  269. myIconFGColor        = "#777777"
  270. myIconBGColor        = "#0f0f0f"
  271. mySeperatorColor     = "#555555"
  272. ------------------------------------------------------------------
  273. -- XPConfig conf ----------------------------------------
  274. myXPConfig = defaultXPConfig
  275.    {
  276.      font = "-*-*-*-*-*--12-*-*-*-*-*-*-*"
  277.    , bgColor =  "#000000"
  278.    , fgColor =  "#ffffff"
  279.    , fgHLight = "#ffffff"
  280.    , bgHLight = "#00ffff"
  281.    , borderColor = "#000000"
  282.    , promptBorderWidth = 1
  283.    , height = 32
  284.    , historySize = 100
  285.    }
  286. -- Window tags
  287. stackPlus s1 s2 = Just W.Stack {W.focus = W.focus s1,
  288.                               W.up    = (W.up s1) ++ (W.up s2),
  289.                               W.down  = (W.down s1) ++ (W.down s2) ++ [W.focus s2]}
  290.  
  291. stackPlus' Nothing st = Just st
  292. stackPlus' (Just s1) s2 = stackPlus s1 s2
  293. modifyWs i d f s = W.modify d f (W.view i s)
  294. emptyCurrentWs = W.modify Nothing (const Nothing)
  295. addStackToTarget target st = modifyWs target st (stackPlus' st)
  296. returnToCurrent c s = W.view curtag s
  297.     where curtag = W.currentTag c
  298.  
  299. curstack s = W.stack $ W.workspace $ W.current s
  300.  
  301. currentList :: X [Window]
  302. currentList = withWindowSet (\s -> return $ W.integrate' $ curstack s)
  303.  
  304. --- [Workspaces] -------------------------------------------------
  305. myWorkspaces =  [ "1:term", "2:web", "3:docs", "4:media", "5:dev"
  306.                , "6:vm", "emacs", "nethack", "hack", "inspection", "T" ]
  307.                ++ [hiddenWorkspaceTag, summonWorkspaceTag]
  308.  
  309. -- | Workspace containing "hidden" windows. Treated specially by workspace handling commands.
  310. hiddenWorkspaceTag :: String
  311. hiddenWorkspaceTag = "H"
  312. -- | Workspace containing "summoned" windows. Treated specially by workspace handling commands.
  313. summonWorkspaceTag :: String
  314. summonWorkspaceTag = "S"
  315.              
  316. -----------------------------------------------------------------
  317. programmingChats = ClassName "Okular" `Or` Title "haskell"
  318. miscChats        = ClassName "URxvt" `Or`  Title "Online"
  319. --proglay = ( (layoutP (RE programmingChats) (relBox 0 0 0.55 1)   (Just $ relBox 0 0 1 1) tall)
  320. --           $ (layoutP (RE miscChats)   (relBox 0.55 0 1 0.6) (Just $ relBox 0.55 0 1 1) tall)
  321. --           $ (layoutAll (relBox 0.55 0.6 1 1) tall)
  322. --           )
  323.  
  324. rt     = ResizableTall 1 (3/100) (1/2) []
  325. rt2    = ResizableTall 1 (3/100) (1/4) []
  326. tall   = named "Tall"   $ subLayout [0,1,2] Simplest  $ rt
  327. mtall  = named "Mirror" $ subLayout [0,1,2] Simplest  $ Mirror rt
  328. imlike = named "imlike" $ reflectHoriz $ combineTwoP (TwoPane 0.03 0.2) mtall mtall (ClassName "Kopete")
  329. imlike2   = named "imlike2" $ reflectHoriz $ combineTwoP (TwoPane 0.03 0.2) Simplest mtall (ClassName "Kopete")
  330. imlike_mtall     = named "imlike" $ reflectHoriz $ combineTwoP (rt2) (mtall) (mtall)    (ClassName "Kopete")
  331. --fullscreenLayout = named "fullscreen" $ noBorders Full
  332.  
  333. tiled            = Tall 1 (1/20) (1/4)
  334. dwmtile          = named "dwm" tiled
  335. mix              = named "mix" $ Tall 1 (1/100) (2/3)
  336. mirrored         = named "mirror" $ Mirror tiled
  337. books            = named "books" (Tall 1 (1/100) (2/3))
  338.  
  339. myLayout = avoidStruts
  340.         $ trackFloating
  341. --       $ magicFocus
  342.         $ windowNavigation
  343. --       $ spacing 4
  344.         $ addTabs shrinkText myTheme
  345.         $ onWorkspace "1:term"  (tall ||| imlike)
  346.         $ onWorkspace  "2:web"  (tall ||| imlike)
  347.         $ tall ||| mtall
  348.  
  349. myManage = composeOne
  350.  [
  351.     transience
  352.   , isFullscreen -?> doFullFloat
  353.   , resource  =? "MainTerminal" -?> doShift "1:term"
  354.   , cl =? "Conky" -?> doShift "inspection"
  355. -- ,(cl =? "Xmessage" -?> doCenterFloat <+> doF W.shiftMaster <+> (ask >>= \w -> =liftX (setOpacity w 0.7) >> idHook))
  356.  
  357. --, className =? "Gimp"           --> fromX (spawn "...")
  358.  
  359.   , cl =? "Firefox"       -?> doShift "2:web"
  360.   , cl =? "Google-chrome" -?> doShift "2:web"
  361.   , cl =? "Okular"        -?> doShift "3:docs"
  362.   , cl =? "Zathura"       -?> doShift "3:docs"
  363.   , ("Gimp" `isPrefixOf`) <$> cl  -?> doShift "4:media"
  364.   , isMPlayerFull         -?> doShift "4:media"
  365.   , cl =? "gmpc"          -?> doShift "4:media"
  366.   , cl =? "VirtualBox"    -?> doShift "6:vm"
  367.   , resource  =? "desktop_window" -?> doIgnore
  368.   , resource  =? "kdesktop"       -?> doIgnore
  369.   , cl =? "XFontSel"              -?> doF W.shiftMaster <+> doCenterFloat
  370.   , isDialog                      -?> doF W.shiftMaster <+> doFloat
  371. -- , return True                   -?> doF W.swapDown
  372.   ]
  373. --  <+> composeOne [className =? c          -?> doShift "4:docs" | c <- ["Xpdf","Zathura"]]
  374. --  <+> composeOne [className =? c          -?> (ask >>= doF . \w -> copyWindow w "2:web") | c <- [ "Conkeror" ,"Dillo" , "Firefox" ]]
  375. --  <+> composeOne [className =? myFloats -?> doFloat
  376. --      | myFloats <- [ "Thunar"  ,"Gimp-2.6" ,"MPlayer", "", "feh", "Qjackctl" ]]
  377. --  <+> composeOne
  378. --  [ sp =? "gimp-image-window"         -?> doCenterFloat
  379. --  , sp =? "gimp-image-new"            -?> doCenterFloat
  380. --  , sp =? "gimp-dock"                 -?> doTopRightFloat
  381. --  , sp =? "gimp-toolbox"              -?> doTopLeftFloat
  382. --  , sp =? "gimp-toolbox-color-dialog" -?> doBottomRightFloat
  383. --  ]
  384.  <+> composeOne [ className =? c -?> (ask >>= \w -> liftX (chooseLayout "imlike") >> idHook ) | c <- [ "Kopete" ]]
  385. -- <+> doFloat
  386.  where isMPlayerFull = (className =? "MPlayer" <&&> appName =? "gl2")
  387.                        <||> title =? "Gnome MPlayer Fullscreen"
  388.        name          = stringProperty "WM_NAME"
  389.        sp            = stringProperty "WM_WINDOW_ROLE"
  390.        cl            = className
  391.  
  392.  
  393. xPropMatches :: [XPropMatch]
  394. xPropMatches  = tagclasses ["Epiphany-browser", "Kontact", "Liferea-bin", "Conkeror", "Firefox"] "web"
  395.             ++ tagclasses ["gimp", "f-spot", "Inkscape", "Eog"] "gfx"
  396.             ++ tagclasses ["gnome-terminal","URxvt"] "term"
  397.             ++ tagclasses ["Gedit", "Leafpad", "Gvim", "Emacs"] "text"
  398.             ++ tagclasses ["Nautilus", "pcmanfm"] "files"
  399.             ++ tagclasses ["Amarok", "Rhythmbox", "Totem", "gmpc"] "media"
  400.             ++ tagclasses ["Kopete"] "kopete"
  401.             ++ tagclasses ["Wxmaxima"] "math"
  402.             ++ tagclasses ["scratchpad"] "scratchpad"
  403.          where
  404.            ckClass cls = [(wM_CLASS, any (cls==))]
  405.            -- добавить тег окну
  406.            tag name  = pmX (addTag name)
  407.            -- добавить тег и переместить окно
  408.            moveAndTag name = (\w -> addTag name w >> return (W.shift name))
  409.            mkfloat = pmX float
  410.            -- пометить тегом все окна с данным классом
  411.            tagclasses clss name = [ (ckClass cls, tag name) | cls <- clss ]
  412.            -- переместить окна с данным классом на воркспейс ws
  413.  
  414. floatPlasma = composeAll
  415.    [ className =? "Qt-subapplication" --> doFloat,
  416.      title =? "Qt-subapplication" --> doFloat,
  417.      className ~? "[pP]lasma-desktop" --> doFloat
  418.    ]
  419.  
  420. myTheme = defaultTheme
  421.    { activeColor         = "#000000"
  422.    , inactiveColor       = "#000000"
  423.    , urgentColor         = "#110000"
  424.    , activeBorderColor   = "#222222"
  425.    , inactiveBorderColor = "#000000"
  426.    , urgentBorderColor   = "#000000"
  427.    , activeTextColor     = "#aaaaaa"
  428.    , inactiveTextColor   = "#888888"
  429.    , urgentTextColor     = "#cc0000"
  430.    , fontName = "" ++ myFont ++ ""
  431.    , decoHeight = 12
  432.    }
  433. myUrgencyHook = withUrgencyHook dzenUrgencyHook
  434.    { args = ["-x", "0", "-y", "1084", "-h", "16", "-w", "1366", "-ta", "r", "-expand", "l", "-fg", "" ++ myUrgentFGColor ++ "", "-bg", "" ++ myNormalBGColor ++ "", "-fn", "" ++ myFont ++ ""] }
  435. -------------------- menuhook --------------------
  436. checkDialog = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG"
  437. checkMenu = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_MENU"
  438. checkDesktop = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
  439. checkDockAtom = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DOCK"
  440. checkOverride = checkAtom "_NET_WM_WINDOW_TYPE" "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE"
  441. checkFullscreen = checkAtom "_NET_WM_STATE" "_NET_WM_STATE_FULLSCREEN"
  442.  
  443. manageMenus = checkMenu --> doFloat
  444. manageDialogs = checkDialog --> doFloat
  445.  
  446. -- Keys ------------------------------------------------------------
  447. toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
  448. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  449.    [((m .|. modm, k), windows $ f i)
  450.     | (i, k) <- zip (workspaces conf) [xK_1 .. ]
  451.     , (f, m) <- [(W.view, 0), (W.shift, shiftMask), (copy, controlMask)]]
  452.     ++ makeKeys apps
  453.     ++ (tagkeys modMask xK_exclam "web")
  454.     ++ (tagkeys modMask xK_numbersign "text")
  455.     ++ (tagkeys modMask xK_slash "gfx")
  456.     ++ (tagkeys modMask xK_semicolon "office")
  457. --   ++ (tagkeys modMask xK_colon "docs")
  458.     ++ (tagkeys modMask xK_question "math")
  459.     ++ (tagkeys modMask xK_asterisk "files")
  460.     ++ (tagkeys modMask xK_percent "im")
  461.  
  462. --   ++ [((0, xK_Menu), submap . M.fromList $
  463. --          [ ((0, xK_n),      spawn "mpc next")
  464. --          , ((0, xK_p),      spawn "mpc prev")
  465. --          , ((0, xK_z),      spawn "mpc random")
  466. --          , ((0, xK_space),  spawn "mpc toggle")
  467. --          , ((0, xK_period), spawn "xdotool key F20")
  468. --    ])]
  469.  
  470. -- | Match a string against any one of a window's class, title, name or
  471. --   role.
  472. matchclass :: String -> Query Bool
  473. matchclass x = foldr ((<||>) . (=? x)) (return False) [className]
  474.  
  475. myDzenPP h = defaultPP
  476.     {
  477.           ppCurrent = wrap "2 ^fg(#00aaff)^bg(#000000)^fg(white)" "^bg()^fg()" . wrap "^fg(#007b8c)[ ^fg()" " ^fg(#007b8c)]^fg()" . \wsId -> dropIx wsId
  478.         , ppVisible = \w -> ""
  479.         , ppSep = ""
  480.         , ppHidden = \w -> ""
  481.         , ppHiddenNoWindows = \w -> ""
  482.         , ppTitle = \w -> ""
  483.         , ppLayout = \w -> ""
  484.         , ppOutput = hPutStrLn h
  485.         }
  486.         where
  487.         dropIx wsId = wsId
  488.  
  489. staticWs = ["1:term", "2:web", "3:docs", "4:media", "5:dev" ]
  490.  
  491. myStatusBar = "dzen2 -x '396' -y '-0' -h '20' -w '80' -ta 'l' -fg '" ++ myNormalFGColor ++ "' -bg '" ++ myNormalBGColor ++ "' -fn '" ++ dzenFont ++ "'"
  492. test = "cat >> ~/dmpipe"
  493. conkywlan = "conky >> ~/dmpipe"
  494. zdzen = "~/bin/zdzen.sh"
  495. conkympd = "conky -c /home/neg/.conkyrc.bck|dzen2 -x '0' -ta 'r' -expand 'l' -y '-1' -h '22'  -fn \"-hell-monobook-bold-r-normal--20-20-72-72-m-100-iso10646-1\""
  496. getdzen = "tail -f ~/dmpipe |dmplex|dzen2 -x '0' -y '-1' -w '768' -h '22' -expand 'r' -fn \"-hell-monobook-bold-r-normal--20-20-72-72-m-100-iso10646-1\""
  497. myBar  = "xmobar"
  498.  
  499. main ::  IO ()
  500. main = do
  501.     xmobar    <- spawnPipe myBar
  502.     xmonad  $ ewmh defaultConfig {
  503.       terminal = "urxvt -e tmux"
  504.     , borderWidth = 1
  505.     , modMask = mod4Mask
  506.    
  507.     , normalBorderColor  = myNormalBorderColor
  508.     , focusedBorderColor = myFocusedBorderColor
  509.     , focusFollowsMouse  = False
  510.  
  511.     , keys          =   myKeys
  512.     , layoutHook    =   myLayout
  513.     , manageHook    = foldr1 (<+>)  
  514.                     [ myManage
  515.                     , (xPropManageHook xPropMatches)
  516.                     , manageMenus
  517.                     , manageDialogs
  518.                     , floatPlasma  
  519.                     , namedScratchpadManageHook scratchpads
  520.                     , manageDocks, raiseHook
  521. --                  , (fmap not isDialog --> doF avoidMaster)
  522. --                  , doF W.swapDown
  523. --                  , doFloat
  524.                     ]
  525.     , workspaces    =   myWorkspaces
  526.     , logHook       =   updatePointer (Relative 0.5 0.5)
  527. --  , logHook       =   (dynamicLogWithPP $ myDzenPP test)
  528. --                      >>  updatePointer (Relative 0.5 0.5)
  529. --                      >> colorWhen (matchclass "dzen2") "#ff00ff"
  530.     , startupHook   =   setWMName "LG3D" >> adjustEventInput
  531.     } `additionalKeysP` addKeys
  532.  
  533.  
  534. -- | Get a list of tuples (tag, [Window]) for each workspace.
  535. taggedWindows :: [W.Workspace i l a] -> [(i, [a])]
  536. taggedWindows = map $ W.tag &&& W.integrate' . W.stack
  537. -- | Get tags with copies of the focused window (if present.)
  538. copiesOfOn :: (Eq a) => Maybe a -> [(i, [a])] -> [i]
  539. copiesOfOn foc tw = maybe [] hasCopyOf foc
  540.  where hasCopyOf f = map fst $ filter ((f `elem` ) . snd) tw
  541.  
  542. runOrDont q act = ifWindows q (const . return $ ()) act
  543. spawnOrDont q cmd = runOrDont q (spawn cmd)
  544. [/code]
  545.  
RAW Paste Data