Guest User

Untitled

a guest
Jan 21st, 2011
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --System imports
  2. import XMonad
  3. import System.Exit
  4. import qualified XMonad.StackSet as W
  5. import qualified Data.Map        as M
  6. import Data.Ratio ((%))
  7. import Data.IORef
  8. import Data.Monoid
  9.  
  10.  
  11. -- Graphics import
  12.  
  13. import Graphics.X11.Xlib.Extras
  14. import Graphics.X11.ExtraTypes.XF86
  15.  
  16. -- Actions import
  17. import XMonad.Actions.CycleWS
  18. import XMonad.Actions.NoBorders
  19. import XMonad.Actions.CopyWindow
  20. import XMonad.Actions.SinkAll
  21. import XMonad.Hooks.DynamicLog
  22. import XMonad.Actions.TagWindows
  23. import XMonad.Actions.UpdatePointer
  24. import qualified XMonad.Actions.FlexibleResize as Flex
  25. import XMonad.Actions.WindowMenu
  26. import XMonad.Actions.GridSelect
  27. import XMonad.Actions.ConstrainedResize as Sqr
  28. import XMonad.Actions.FlexibleResize
  29. import XMonad.Actions.FindEmptyWorkspace
  30. import XMonad.Actions.RotSlaves
  31. import XMonad.Actions.FocusNth
  32. import XMonad.Actions.Submap
  33. --import XMonad.Actions.CycleSelectedLayouts
  34. --import XMonad.Actions.Search
  35. -- Layouts
  36. --import xmproc
  37. import XMonad.Layout.Circle
  38. import XMonad.Layout.NoBorders
  39. import XMonad.Layout.Tabbed
  40. -- import XMonad.Layout.DwmStyle
  41. import XMonad.Layout.Named
  42. import XMonad.Layout.Master
  43. import XMonad.Layout.Decoration
  44. import XMonad.Layout.PerWorkspace
  45. import XMonad.Layout.Named
  46. import XMonad.Layout.IM
  47. import XMonad.Layout.Reflect
  48. import XMonad.Layout.MagicFocus
  49. import XMonad.Layout.LayoutModifier
  50. import XMonad.Layout.MultiToggle
  51. import XMonad.Layout.NoBorders
  52. import XMonad.Layout.TwoPane
  53. import XMonad.Layout.ResizableTile
  54. import XMonad.Layout.Spiral
  55. import XMonad.Layout.StackTile
  56. import XMonad.Layout.Mosaic
  57. import XMonad.Layout.MosaicAlt
  58. -- import XMonad.Layout.Dishes
  59. import XMonad.Layout.Gaps
  60. import XMonad.Layout.Grid
  61. import XMonad.Layout.MouseResizableTile
  62. import XMonad.Layout.Simplest
  63. import XMonad.Layout.SimplestFloat
  64. import XMonad.Layout.OneBig
  65. import XMonad.Layout.Minimize
  66. import XMonad.Layout.Maximize
  67. --import XMonad.Layout.Accordion
  68. --import XMonad hiding ( (|||) )
  69. --import XMonad.Layout.LayoutCombinators
  70. import XMonad.Layout.WindowNavigation
  71. import XMonad.Layout.SimpleFloat
  72. import XMonad.Layout.SimplestFloat
  73. import XMonad.Layout.CenteredMaster
  74. import XMonad.Layout.SimpleDecoration
  75. import XMonad.Layout.ShowWName
  76. import XMonad.Layout.DecorationMadness
  77.  
  78. -- Prompt import
  79. import XMonad.Prompt
  80. import XMonad.Prompt.Man
  81. import XMonad.Prompt.Shell
  82. import XMonad.Prompt.Ssh
  83. import XMonad.Prompt.Input
  84. --
  85. import XMonad.Prompt.Workspace
  86. --import XMonad.Prompt.Layout
  87. --import XMonad.Prompt.RunOrRaise
  88.  
  89. -- Hooks import
  90. import XMonad.Hooks.UrgencyHook
  91. import XMonad.Hooks.EwmhDesktops
  92. import XMonad.Hooks.ManageDocks
  93. import XMonad.Hooks.ManageHelpers
  94. import XMonad.Hooks.FadeInactive
  95. import XMonad.Hooks.DynamicLog
  96. import XMonad.Hooks.Place
  97. import XMonad.Hooks.RestoreMinimized
  98.  
  99.  
  100. --
  101. -- import XMonad.Util.EZConfig
  102. -- Tobe able to query X11 atoms and such on
  103. -- X11 import
  104. import Graphics.X11.Xlib.Display
  105. import Graphics.X11.Xlib.Screen
  106. import Graphics.X11.Xlib.Extras
  107. import Graphics.X11.Types
  108. import Graphics.X11.ExtraTypes.XF86
  109. import Graphics.X11.ExtraTypes.XorgDefault
  110. import Foreign.C.Types (CLong)
  111. import Text.Regex.Posix ((=~))
  112. --import utils
  113. import XMonad.Util.XUtils
  114. import XMonad.Util.Run
  115. import XMonad.Util.CustomKeys
  116.  
  117. --import XMonad.Util.Dzen
  118.  
  119.  
  120. myTerminal      = "gnome-terminal"
  121. myBorderWidth   = 1
  122. myModMask       = mod1Mask
  123. myFadeIn = 0.7
  124. -- > $ xmodmap | grep Num
  125. -- > mod2        Num_Lock (0x4d)
  126. --
  127. -- Set numlockMask = 0 if you don't have a numlock key, or want to treat
  128. -- numlock status separately.
  129. --
  130. myNumlockMask   = mod2Mask
  131. myWorkspaces = ["sys","im","sip","mail","www","tab","graph", "files", "media"]
  132. myNormalBorderColor  = "#cccccc"
  133. --myNormalBorderColor  = "#ffffff"
  134. myFocusedBorderColor = "#000000"
  135. myBar = "conky"
  136.  
  137. setRootAtom :: String -> String -> X ()
  138. setRootAtom name value = withDisplay (io . setRootAtom' name value)
  139.    where setRootAtom' atom name d = do
  140.                                        a <- internAtom d atom False
  141.                                        rw <- rootWindow d $ defaultScreen d
  142.                                        setTextProperty d rw name a
  143.  
  144. getRootAtom :: String -> X [String]
  145. getRootAtom name = withDisplay (io . getRootAtom' name)
  146.    where getRootAtom' atom d = do
  147.             a <- internAtom d atom False
  148.             rw <- rootWindow d $ defaultScreen d
  149.             tp <- getTextProperty d rw a
  150.             wcTextPropertyToTextList d tp
  151.  
  152. setLayoutAtom :: String -> X ()
  153. setLayoutAtom name =  setRootAtom "XMONAD_LAYOUT" name
  154.  
  155. -- chooseLayout name = sendMessage $ JumpToLayout name
  156.  
  157. --
  158.  
  159. -- Window tags
  160.  
  161. stackPlus s1 s2 = Just W.Stack {W.focus = W.focus s1,
  162.                                W.up    = (W.up s1) ++ (W.up s2),
  163.                                W.down  = (W.down s1) ++ (W.down s2) ++ [W.focus s2]}
  164.  
  165. stackPlus' Nothing st = Just st
  166. stackPlus' (Just s1) s2 = stackPlus s1 s2
  167.  
  168. modifyWs i d f s = W.modify d f (W.view i s)
  169.  
  170. emptyCurrentWs = W.modify Nothing (const Nothing)
  171.  
  172. addStackToTarget target st = modifyWs target st (stackPlus' st)
  173.  
  174. returnToCurrent c s = W.view curtag s
  175.    where curtag = W.currentTag c
  176.  
  177. curstack s = W.stack $ W.workspace $ W.current s
  178. -- CompizFusion or MS Win Se7en like
  179. currentList :: X [Window]
  180. currentList = withWindowSet (\s -> return $ W.integrate' $ curstack s)
  181.  
  182. unmaximize :: Window -> X ()
  183. unmaximize w = withDisplay $ unmaximize' w
  184.  where
  185.    unmaximize' w d =
  186.       let swd = widthOfScreen s
  187.           sht = heightOfScreen s
  188.           wd = round $ 0.8*(fromIntegral swd)
  189.           ht = round $ 0.8*(fromIntegral sht)
  190.           x = round $ (fromIntegral (swd-wd))/2
  191.           y = round $ (fromIntegral (sht-ht))/2
  192.           s = defaultScreenOfDisplay d
  193.      in do float w
  194.            io $ resizeWindow d w wd ht
  195.            io $ moveWindow d w x y
  196.  
  197. isFloat :: Window -> X Bool
  198. isFloat w = do
  199.   fls <- withWindowSet (return . W.floating)
  200.   return (w `M.member` fls)
  201.  
  202. specialMove w = do
  203.   focus w
  204.   lst <- currentList
  205.   case lst of
  206.     [] -> return ()
  207.     [x] -> do
  208.       is <- isFloat x
  209.       if is
  210.         then mouseMoveWindow w
  211.         else float x >> unmaximize x
  212.     _ -> mouseMoveWindow w
  213.  
  214. ------------------------------------------------------------------------
  215. -- Взять значение свойства окна
  216. getProp :: Atom -> Window -> X (Maybe [CLong])
  217. getProp a w = withDisplay $ \dpy -> io $ getWindowProperty32 dpy a w
  218.  
  219. -- Эта функция проверяет, выставлено ли свойство окна name в значение value
  220. checkAtom name value = ask >>= \w -> liftX $ do
  221.           a <- getAtom name
  222.           val <- getAtom value
  223.           mbr <- getProp a w
  224.           case mbr of
  225.             Just [r] -> return $ elem (fromIntegral r) [val]
  226.             _ -> return False
  227. -- Эта функция проверяет, является ли окно диалогом ли tear-off меню
  228. checkDialog = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG"
  229. checkMenu = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_MENU"
  230.  
  231. -- Сделать меню плавающими
  232. --manageMenus = checkMenu --> doFloat
  233. -- Сделать диалоги плавающими
  234. --manageDialogs = checkDialog --> doFloat
  235.  
  236. manageMenus=checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG" --> doFloat
  237. manageDialogs = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_MENU" --> doFloat
  238. ------------------------------------------------------------------------
  239. -- Key bindings. Add, modify or remove key bindings here.
  240. --
  241. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  242.  
  243.     [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  244.      --, ((modm .|. controlMask, xK_d), spawn "oowriter")
  245.      , ((modm .|. controlMask, xK_d), spawn "/opt/openoffice.org3/program/swriter")
  246.      , ((shiftMask .|. modm .|. controlMask, xK_d), spawn "abiword")
  247.      --, ((modm .|. controlMask, xK_e), spawn "oocalc")
  248.      , ((modm .|. controlMask, xK_e), spawn "/opt/openoffice.org3/program/scalc")
  249.      , ((shiftMask .|. modm .|. controlMask, xK_e), spawn "gnumeric")
  250.      --, ((modm .|. controlMask, xK_p), spawn "ooimpress")
  251.      , ((modm .|. controlMask, xK_p), spawn "/opt/openoffice.org3/program/simpress")
  252.      , ((shiftMask .|. modm .|. controlMask, xK_p), spawn "lyx")
  253.      , ((modm .|. controlMask, xK_o), spawn "xterm -e /home/AlexYeCu/xnest")
  254.      , ((shiftMask .|. modm .|. controlMask, xK_o), spawn "evolution")
  255.      --, ((mod4Mask, xK_e ), spawn "urxvt")
  256.      , ((mod4Mask, xK_e ), spawn "gnome-terminal")
  257.      , ((shiftMask .|. mod4Mask, xK_e ), spawn "xterm")
  258.      , ((controlMask .|. mod4Mask, xK_e ), spawn "gnome-terminal")
  259.      , ((modm .|. mod4Mask, xK_e ), spawn "xterm")
  260.      , ((mod4Mask, xK_period ), spawn "ellipses")  
  261.      , ((mod4Mask, xK_w ), spawn "wacommode")
  262.      , ((mod4Mask, xK_h), spawn "gedit ~/.xmonad/xmonad.hs")
  263.      , ((mod4Mask, xK_a), spawn "gedit ~/bin/autostart")
  264.      , ((mod4Mask, xK_c), spawn "/home/AlexYeCu/bin/clipthis")
  265.      , ((mod4Mask, xK_t), spawn "/home/AlexYeCu/bin/translit")
  266.      ,((mod4Mask, xK_v), spawn "gthumb vi-vim-cheat-sheet.gif")
  267.      ,((mod4Mask, xK_q), spawn "echo $ELLE")
  268.      , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  269.      , ((modm,               xK_f     ), spawn "exe=`fmenu_path | fmenu` && eval \"exec $exe\"")
  270.      --, ((modm,               xK_v     ), spawn "exe=`vmenu_path | vmenu` && eval \"exec $exe\"")
  271.      , ((controlMask .|. modm, xK_BackSpace), spawn "sudo killall -9 X")
  272.      , ((modm .|. shiftMask , xK_period), spawn "echo …")
  273. --XF86Sleep 0x1008ff10
  274.      , ((0, xF86XK_Sleep ), spawn "slock")
  275.  
  276.     , ((controlMask, xF86XK_Sleep ), spawn "xterm -e /home/AlexYeCu/bin/off")
  277. --
  278.      , ((0, xK_Print ), spawn "scrot")
  279.     -- launch gmrun
  280.     , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
  281.     , ((modm,               xK_r     ), spawn "gmrun")
  282.     -- close focused window
  283.     , ((modm .|. shiftMask, xK_c     ), kill)
  284.     , ((mod4Mask, xK_z ), kill)
  285.     , ((mod4Mask, xK_x ), spawn "xkill")
  286. --XF86Mail 0x1008ff19
  287.     , ((shiftMask, 0x1008ff19 ), spawn "opera")
  288.     , ((0, 0x1008ff19 ), spawn "firefox")
  289.     , ((modm, 0x1008ff19 ), spawn "epiphany")
  290.     , ((controlMask, 0x1008ff19 ), spawn "google-chrome")
  291.     , ((mod4Mask, 0x1008ff19 ), spawn "arora")
  292.    -- , ((mod3Mask, 0x1008ff19 ), spawn "konqueror")
  293. --XF86Home 0x1008ff33
  294.     , ((0, xF86XK_HomePage), spawn "nautilus $HOME")
  295.     --, ((shiftMask, xF86XK_HomePage ), spawn "krusader")
  296.     --, ((mod4Mask, xF86XK_HomePage ), spawn "thunar $HOME")
  297.     --, ((mod4Mask, xF86XK_HomePage ), spawn "gentoo")
  298.     , ((controlMask, xF86XK_HomePage ), spawn "pcmanfm")
  299.     --, ((modm, xF86XK_HomePage ), spawn "dolphin $HOME")
  300.     , ((shiftMask, xF86XK_HomePage ), spawn "gnome-commander")
  301. --XF86WebCam 0x1008ff8f
  302. --    , ((0, xF86XK_WebCam), spawn "camx")
  303. --XF86Favorites 0x1008ff30
  304.     , ((shiftMask, xF86XK_Favorites ), spawn "gogh")
  305.     , ((0, xF86XK_Favorites ), spawn "gcolor2")
  306.     , ((controlMask, xF86XK_Favorites ), spawn "xournal")
  307. --XF86Search 0x1008ff1b
  308.     , ((0, xF86XK_Search ), spawn "~/bin/mpcpult")
  309.     , ((shiftMask, xF86XK_Search ), spawn "beagle-search")
  310.     , ((controlMask, xF86XK_Search ), spawn "~/bin/websearch")
  311. --XF86Back 0x1008ff26
  312.     --, ((controlMask .|. shiftMask, xF86XK_Back ), sendMessage $ ToggleGaps)  -- toggle all gaps
  313.     , ((shiftMask, xF86XK_Back ), spawn "killall -9 xmobar")
  314.     --, ((controlMask, xF86XK_Back ), sendMessage $ ToggleGap U) -- toggle the top gap
  315.     --, ((modm, xF86XK_Back ), spawn "~/bin/bga")
  316.     --, ((mod4Mask, xF86XK_Back ), spawn "killall xcompmgr | killall cairo-compmgr")
  317.     , ((0, xF86XK_Back ), spawn "~/bin/dvdeject")
  318. --XF86Forward 0x1008ff27
  319.     --, ((controlMask .|. shiftMask, xF86XK_Forward ), sendMessage ToggleStruts)
  320.     , ((shiftMask, xF86XK_Forward ), spawn "/home/AlexYeCu/.cabal/bin/xmobar")
  321.     --, ((modm, xF86XK_Forward ), spawn "~/bin/bgb")
  322.     , ((0, xF86XK_Forward ), spawn "gmrun")
  323.     --, ((mod4Mask, xF86XK_Forward ), spawn "xcompmgr -cfFS -r 0 -o 0 -D 10 -I 0.1 -O 0.1 &")
  324.    --,((mod4Mask, xF86XK_Forward ), spawn "xcompmgr")
  325.    --,((shiftMask .|. mod4Mask, xF86XK_Forward ), spawn "/usr/local/bin/cairo-compmgr")
  326. --XF86Stop xK_Cancel 0x1008ff28
  327.     , ((0, xK_Cancel ), spawn "~/bin/camx")
  328.     , ((shiftMask, xK_Cancel ), spawn "~/bin/webcam -p")
  329.     , ((modm, xK_Cancel ), spawn "kill -9 `/usr/sbin/lsof -t /dev/video0`")
  330.     , ((controlMask .|. modm, xK_Cancel ), spawn "v4l2ucp")
  331.     , ((controlMask, xK_Cancel ), spawn "~/bin/camrec -f")
  332.     , ((mod4Mask, xK_Cancel), spawn "~/bin/camrec -j")
  333. --XF86Refresh 0x1008ff73
  334.     , ((0, xF86XK_Refresh), spawn "tomboy --new-note $(date +%Y-%m-%d_%H:%M:%S)")
  335.     , ((shiftMask, xF86XK_Refresh), spawn "gedit")
  336.     , ((controlMask, xF86XK_Refresh), spawn "gvim")
  337.     , ((mod4Mask, xF86XK_Refresh), spawn "~/bin/clipthis")
  338.     , ((0, xF86XK_Reload), spawn "tomboy --new-note $(date +%Y-%m-%d_%H:%M:%S)")
  339.     , ((shiftMask, xF86XK_Reload), spawn "gedit")
  340.     , ((controlMask, xF86XK_Reload), spawn "gvim")
  341.     , ((mod4Mask, xF86XK_Reload), spawn "~/bin/clipthis")
  342. --XF86AudioPrev 0x1008ff16
  343.    --, ((0, xF86XK_AudioPrev  ),      spawn "amarok --previous")
  344.    , ((0, xF86XK_AudioPrev),      spawn "mpc prev")
  345.    , ((shiftMask, xF86XK_AudioPrev),       spawn "mocp --prev")
  346.    , ((controlMask, xF86XK_AudioPrev),       spawn "mpc seek -10%")
  347.    , ((mod4Mask, xF86XK_AudioPrev),       spawn "mpc seek -00:00:30")
  348. --XF86AudioNext 0x1008ff17
  349.      , ((0, xF86XK_AudioNext ),       spawn "mpc next")
  350.      , ((shiftMask, xF86XK_AudioNext ),       spawn "mocp --next")
  351.      , ((controlMask, xF86XK_AudioNext ),       spawn "mpc seek +10%")
  352.      , ((mod4Mask, xF86XK_AudioNext ),       spawn "mpc seek +00:00:30")
  353. --XF86AudioStop 0x1008ff15
  354.    --, ((0, xF86XK_AudioStop),       spawn "amarok --stop")    
  355.      , ((0, xF86XK_AudioStop),        spawn "mocp --stop")
  356. --XF86Play 0x1008ff14
  357.      , ((0, xF86XK_AudioPlay),        spawn "mpc toggle")
  358.      , ((0, xF86XK_AudioPlay),        spawn "mpc toggle")
  359.      , ((mod4Mask, xF86XK_AudioPlay),        spawn "gmpc")
  360.      , ((shiftMask, xF86XK_AudioPlay),        spawn "mocp -G")
  361. --XF86AudioMute 1008ff12
  362.     , ((0, xF86XK_AudioMute),        spawn "amixer -c0 set Master 0% 0%")
  363.      , ((modm, xF86XK_AudioMute),        spawn "~/bin/headphones -m")
  364.      -- , ((0, xF86XK_AudioMute),        spawn "amixer -c0 set Master toggle")
  365.      , ((controlMask, xF86XK_AudioMute),        spawn "amixer -c0 set Mic 0% 0%")
  366.      , ((controlMask .|. shiftMask , xF86XK_AudioMute),        spawn "amixer -c7 set Mic 0% 0%")
  367.      , ((shiftMask, xF86XK_AudioMute),        spawn "amixer -c0 set Front 0% 0%")
  368.      , ((mod4Mask, xF86XK_AudioMute),        spawn "~/bin/mic")
  369.      , ((controlMask .|. mod4Mask, xF86XK_AudioMute),        spawn "amixer -c0 set Front 75% 75%")
  370. --XF86AudioLowerVolume 0x1008ff11
  371.     --, ((0, xF86XK_AudioLowerVolume), spawn "amixer -c0 set Master 5dB-")
  372.     --, ((controlMask, xF86XK_AudioLowerVolume), spawn "amixer -c0 set Mic 5dB-")
  373.     --, ((shiftMask, xF86XK_AudioLowerVolume), spawn "amixer -c0 set Front 5dB-")
  374.     , ((0, xF86XK_AudioLowerVolume), spawn "amixer -c0 set Master 5%-")
  375.     , ((controlMask, xF86XK_AudioLowerVolume), spawn "amixer -c0 set Mic 5%-")
  376.     , ((controlMask .|. shiftMask , xF86XK_AudioLowerVolume), spawn "amixer -c7 set Mic 5%-")
  377.     , ((shiftMask, xF86XK_AudioLowerVolume), spawn "amixer -c0 set Front 5%-")
  378.    , ((modm, xF86XK_AudioLowerVolume), spawn "~/bin/headphones -l")
  379. --XF86AudioRaiseVolume 0x1008ff13
  380.     --, ((0, xF86XK_AudioRaiseVolume), spawn "amixer -c0 set Master 5dB+")
  381.     --, ((controlMask, xF86XK_AudioRaiseVolume), spawn "amixer -c0 set Mic 5dB+")
  382.     --, ((shiftMask, xF86XK_AudioRaiseVolume), spawn "amixer -c0 set Front 5dB+")
  383.     , ((0, xF86XK_AudioRaiseVolume), spawn "amixer -c0 set Master 5%+")
  384.     , ((controlMask, xF86XK_AudioRaiseVolume), spawn "amixer -c0 set Mic 5%+")
  385.    , ((controlMask .|. shiftMask , xF86XK_AudioRaiseVolume), spawn "amixer -c7 set Mic 5%+")
  386.     , ((shiftMask, xF86XK_AudioRaiseVolume), spawn "amixer -c0 set Front 5%+")
  387.     , ((modm, xF86XK_AudioRaiseVolume), spawn "~/bin/headphones -h")
  388.      -- Rotate through the available layout algorithms
  389.     , ((modm,               xK_space ), sendMessage NextLayout)
  390.     --, ((mod4Mask,               xK_space ), sendMessage PreviousLayout)
  391.     --  Reset the layouts on the current workspace to default
  392.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  393.  
  394.     -- Resize viewed windows to the correct size
  395.     , ((modm .|. controlMask,               xK_r     ), refresh)
  396.  
  397.     -- Move focus to the next window
  398.     , ((modm,               xK_Tab   ), windows W.focusDown)
  399.  
  400.     -- Move focus to the previous window
  401.     , ((mod4Mask,               xK_Tab     ), windows W.focusUp  )
  402.  
  403. -- Alt+k n Windows switch
  404.  
  405.    --[
  406.      --   ((modMask , xK_k), submap . M.fromList $
  407.        -- [((0, k), focusNth i) | (i, k) <- zip [0 .. 8] [xK_1 ..]])
  408.         --]
  409.  
  410.  
  411.  
  412.  --Window navigator
  413.     , ((modm .|. shiftMask,   xK_Right), sendMessage $ Go R)
  414.     , ((modm .|. shiftMask,   xK_Left ), sendMessage $ Go L)
  415.     , ((modm .|. shiftMask,   xK_Up   ), sendMessage $ Go U)
  416.     , ((modm .|. shiftMask,   xK_Down ), sendMessage $ Go D)
  417.     , ((modm .|. controlMask, xK_Right), sendMessage $ Swap R)
  418.     , ((modm .|. controlMask, xK_Left ), sendMessage $ Swap L)
  419.     , ((modm .|. controlMask, xK_Up   ), sendMessage $ Swap U)
  420.     , ((modm .|. controlMask, xK_Down ), sendMessage $ Swap D)
  421.  
  422. -- Rotate slaves
  423.    , ((modm .|. shiftMask, xK_Tab   ), rotSlavesUp)
  424.  
  425.     -- Move focus to the master window
  426.     , ((mod4Mask, xK_m ), windows W.focusMaster  )
  427.  
  428.     -- Swap the focused window and the master window
  429.     , ((modm,               xK_Return), windows W.swapMaster)
  430.  
  431.     -- Swap the focused window with the next window
  432.     , ((mod4Mask, xK_Down     ), windows W.swapDown  )
  433.  
  434.     -- Swap the focused window with the previous window
  435.     , ((mod4Mask, xK_Up     ), windows W.swapUp    )
  436.  
  437.     -- Shrink the master area
  438.     , ((modm,               xK_h     ), sendMessage Shrink)
  439.  
  440.     -- Expand the master area
  441.     , ((modm,               xK_l     ), sendMessage Expand)
  442.  
  443.     -- Push window back into tiling
  444.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  445.  
  446.     -- Increment the number of windows in the master area
  447.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  448.  
  449.     -- Deincrement the number of windows in the master area
  450.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  451.  
  452.     -- toggle the status bar gap (used with avoidStruts from Hooks.ManageDocks)
  453.     , ((modm .|. controlMask, xK_b ), sendMessage ToggleStruts)
  454.     , ((modm, xK_d ), sendMessage ToggleStruts)
  455.    
  456. --menu max min
  457.     , ((modm, xK_backslash), withFocused (sendMessage . maximizeRestore))
  458.     , ((modm,               xK_o ), windowMenu)
  459.     , ((modm,               xK_slash     ), withFocused (\f -> sendMessage (MinimizeWin f)))
  460.     , ((modm .|. shiftMask, xK_slash     ), sendMessage RestoreNextMinimizedWin)
  461.  
  462.  
  463.     -- Quit xmonad
  464.     , ((modm .|. shiftMask, xK_f     ),  io (exitWith ExitSuccess))
  465.  
  466.     -- Restart xmonad
  467.     , ((modm              , xK_q     ), restart "xmonad" True)
  468.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  469.  
  470. --Combinators
  471. --, ((modm,  xK_t ),   cycleThroughLayouts ["Tall", "Mirror Tall", "Full"])
  472. --, ((modm .|. controlMask, xK_f), sendMessage $ JumpToLayout "Full")
  473.  
  474. -- ResizebleYile
  475.     , ((modm,               xK_a), sendMessage MirrorShrink)
  476.     , ((modm,               xK_z), sendMessage MirrorExpand)
  477. -- MosaicAlt
  478.      , ((modm .|. shiftMask  , xK_s    ), withFocused (sendMessage . tallWindowAlt))
  479.      , ((modm .|. shiftMask  , xK_w    ), withFocused (sendMessage . wideWindowAlt))
  480.      , ((modm .|. controlMask, xK_space), sendMessage resetAlt)
  481. -- MouseResizable
  482.      , ((modm,               xK_b), sendMessage ShrinkSlave) -- %! Shrink a slave area
  483.      , ((modm,               xK_n), sendMessage ExpandSlave) -- %! Expand a slave area
  484.  
  485. -- Gaps
  486.     , ((modm .|. controlMask, xK_g), sendMessage $ ToggleGaps)  -- toggle all gaps
  487.     , ((modm .|. controlMask, xK_t), sendMessage $ ToggleGap U) -- toggle the top gap
  488.     --, ((modm .|. controlMask, xK_w), sendMessage $ IncGap R 5)  -- increment the right-hand gap
  489.     --, ((modm .|. controlMask, xK_q), sendMessage $ DecGap R 5)  -- decrement the right-hand gap
  490. --prompt
  491.     -- , ((mod4Mask, xK_a     ), sendMessage NextLayout >> (dynamicLogString myLogHookD >>= \d->spawn $"xmessage "++d))
  492. --utils
  493.  
  494. --reflect
  495.     , ((modm .|. controlMask, xK_x), sendMessage $ Toggle REFLECTX)
  496.     , ((modm .|. controlMask, xK_y), sendMessage $ Toggle REFLECTY)
  497. --grid
  498.    , ((modm, xK_g), goToSelected defaultGSConfig)
  499.  
  500.    , ((modm,                xK_e    ), viewEmptyWorkspace)
  501.  
  502.    -- , ((modm .|. shiftMask,  xK_e    ), tagToEmptyWorkspace)
  503.  
  504.     ]
  505.     ++
  506.     --E
  507.     -- mod-[1..9], Switch to workspace N
  508.     -- mod-shift-[1..9], Move client to workspace N
  509.     --
  510.     [((m .|. modm, k), windows $ f i)
  511.         | (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9])
  512.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  513.     ++
  514.  
  515.     --
  516.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  517.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  518.     --
  519.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  520.       | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  521.       , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  522. ------------------------------------------------------------------------
  523. -- Mouse bindings: default actions bound to mouse events
  524.  
  525. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  526.  
  527.     -- mod-button1, Set the window to floating mode and move by dragging
  528.     [ --((modMask, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.swapMaster))
  529.       ((modMask, button1), specialMove)
  530.  
  531.     -- mod-button2, Raise the window to the top of the stack
  532.     , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
  533.  
  534.     -- mod-button3, Set the window to floating mode and resize by dragging
  535.     --, ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
  536.     , ((mod4Mask, button3),               (\w -> focus w >> Sqr.mouseResizeWindow w False))
  537.     , ((mod4Mask .|. shiftMask, button3), (\w -> focus w >> Sqr.mouseResizeWindow w True ))
  538.     , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
  539.  
  540.  
  541.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  542.     ]
  543.  
  544. -- Window rules:
  545.  
  546. -- To find the property name associated with a program, use
  547. -- > xprop | grep WM_CLASS
  548. -- and click on the client you're interested in.
  549. --
  550. -- To match on the WM_NAME, you can use 'title' in the same way that
  551. -- 'className' and 'resource' are used below.
  552. --
  553. myManageHook = composeAll
  554.     [ className =? "MPlayer"        --> doCenterFloat
  555.     , className =? "Vlc"       --> doCenterFloat
  556.     , className =? "Sonata"       --> doCenterFloat
  557.     , className =? "Terminal"       --> doCenterFloat
  558.     --, className =? "URxvt"       --> doCenterFloat
  559.     , className =? "kmplayer"       --> doCenterFloat
  560.     , className =? "Search"       --> doCenterFloat
  561.     , className =? "VNC Viewer: Connection Options"       --> doCenterFloat
  562.     , className =? "VNC Authentication [VncAuth]"       --> doCenterFloat
  563.     , className =? "VNC Viewer: Connection Details"       --> doCenterFloat
  564.     , className =? "Vnciewer"       --> doCenterFloat
  565.     , className =? "Multisync-gui"       --> doCenterFloat
  566.     , className =? "Ucview"       --> doCenterFloat
  567.     , className =? "V4l2ucp" --> doCenterFloat
  568.     , className =? "Search"       --> doCenterFloat
  569.     , className =? "Tomboy"       --> doCenterFloat
  570.     , className =? "Gnote"       --> doCenterFloat
  571.     , className =? "xclock"       --> doFloat
  572.     , className =? "Bluetooth-properties"       --> doFloat
  573.     , className =? "Xdialog"       --> doFloat
  574.     , className =? "Zenity"       --> doFloat
  575.     , className =? "wesnoth"       --> doFloat
  576.     , className =? "Gnash"       --> doFloat
  577.     , className =? "v4l2-tool"       --> doFloat
  578.     , className =? "gcalctool"       --> doFloat
  579.     , className =? "org-alchemy-core-Alchemy"       --> doFloat
  580.     , className =? "v4l2ucp"       --> doFloat
  581.     , className =? "Wine"       --> doFloat
  582.     , className =? "Dolphin"       --> doFloat
  583.     , className =? "Gogh"       --> doFloat
  584.     , className =? "Flash.exe"       --> doFloat
  585.     , className =? "Qjackctl"       --> doFloat
  586.     , className =? "Gimp"           --> doF (W.shift "graph")
  587.     , className =? "Ufraw"           --> doF (W.shift "graph")
  588.     , className =? "mypaint"           --> doF (W.shift "graph")
  589.     , className =? "XXkb"           --> doIgnore
  590.     , className =? "Conky"          --> doIgnore
  591.     , className =? "stalonetray"    --> doIgnore
  592.     -- , className =? "lxpanel"    --> doIgnore
  593.     , className =? "avant-window-navigator"    --> doIgnore
  594.     , className =? "Stalonetray"    --> doIgnore
  595.     , resource  =? "desktop_window" --> doIgnore
  596.     , resource  =? "kdesktop"       --> doIgnore
  597.     , resource  =? "gwenview"       --> doFloat
  598.     , resource  =? "webcamstudio"       --> doFloat
  599.     , resource  =? "glxgears"       --> doFloat
  600.     , className =? "Sylpheed"       --> doF (W.shift "mail")
  601.     , className =? "Sylpheed-claws"       --> doF (W.shift "mail")
  602.     , className =? "Kmail"       --> doF (W.shift "mail")
  603.     , className =? "Evolution"       --> doF (W.shift "mail")
  604.     , className =? "Ekiga"          --> doF (W.shift "sip")
  605.     , className =? "Skype"          --> doF (W.shift "sip")
  606.     , className =? "Liferea-bin"        --> doF (W.shift "www")
  607.     , className =? "Akregator"        --> doF (W.shift "www")
  608.     , className =? "Firefox"        --> doF (W.shift "www")
  609.     , className =? "Navigator"        --> doF (W.shift "www")
  610.     , className =? "RSSOwl"        --> doF (W.shift "www")
  611.     , className =? "Pidgin"         --> doF (W.shift "im")
  612.     , className =? "OpenOffice.org 3.0"       --> doF (W.shift "tab")
  613.     , className =? "Lyx"       --> doF (W.shift "tab")
  614.     , className =? "Abiword"       --> doF (W.shift "tab")
  615.     , className =? "Gnumeric"       --> doF (W.shift "tab")
  616.     , className =? "Emacs"          --> doF (W.shift "sys")
  617.     , className =? "Xterm"          --> doCenterFloat
  618.     , className =? "Amarok"          --> doF (W.shift "media")
  619.     , className =? "Webcamsudio"          --> doF (W.shift "sip")
  620.     --, className =? "vlc"          --> doF (W.shift "media")
  621.     , className =? "Krusader"       --> doF (W.shift "files")
  622.     , className =? "Xnest"          --> doF (W.shift "media")
  623.     , className =? "Konqueror"          --> doF (W.shift "www")
  624.     , className =? "Bluetooth-sendto"  --> doFloat
  625.     , className =? "Gloobus-preview" --> doFloat
  626.     , className =? "CinePaint"                  --> doFloat
  627.  ]
  628. myManageHook2 = composeOne
  629.    [ isFullscreen -?> doFullFloat ]
  630. -- Whether focus follows the mouse pointer.
  631. --myFocusFollowsMouse :: Bool
  632. myFocusFollowsMouse = True
  633. --myFocusFollowsMouse = False
  634.  
  635. gimp = withIM (0.16) (Role "gimp-toolbox") $
  636.              reflectHoriz $
  637.              withIM (0.16) (Role "gimp-dock") (maximize(minimize(windowNavigation (OneBig (3/4) (3/4)))))
  638.  
  639.  
  640. myTabConfig = defaultTheme { inactiveBorderColor = "#CCCCCC"
  641.                                    , activeTextColor = "#000000"
  642.                                    , decoHeight = 20
  643.                                    ,fontName = "xft:terminus:size=10"}
  644.  
  645. gimpt = withIM (0.16) (Role "gimp-toolbox") $
  646.              reflectHoriz $
  647.              withIM (0.16) (Role "gimp-dock") (noBorders (tabbedAlways shrinkText myTabConfig))
  648.  
  649. --skype=withIM (1%4) (Role "MainWindow") (maximize(minimize(windowNavigation ((mosaic 1.5 [])))))
  650. --skype = withIM (1%4) (Title "nonameandnick - Skype™ (Beta)" ) $
  651. -- (maximize(minimize(windowNavigation ((mosaic 1.5 [])))))
  652. skype = withIM (1%4) (Role "buddy_list") $
  653.  (maximize(minimize(windowNavigation ((mosaic 1.5 [])))))
  654. -----------------------------------------------------------------------
  655. --myLogHookF :: X ()
  656. myLogHookD :: X ()
  657. --myLogHookD = dynamicLog
  658. myLogHookD = dynamicLogWithPP myPP
  659. --myLogHookD = dynamicLogWithPP dzen2PP
  660. --myLogHookF = fadeInactiveLogHook fadeAmount
  661.      --where fadeAmount = 0.8
  662. myPP ding = xmobarPP { ppCurrent = xmobarColor "orange" "" . wrap "[" "]"  
  663.                  ,ppOutput = hPutStrLn ding
  664.                  , ppLayout  = xmobarColor "yellow" "" . wrap "[" "]"
  665.                  , ppTitle   = xmobarColor "white"  "" . shorten 40
  666.                  , ppVisible = wrap "(" ")"
  667.                  , ppUrgent = xmobarColor "black" "red" . xmobarStrip
  668.          ,ppExtras = []
  669.                  }
  670.  
  671.  
  672. dzen2PP = dzenPP { ppCurrent  = dzenColor "white" "#2b4f98" . pad
  673.                      , ppVisible  = dzenColor "black" "#999999" . pad
  674.                      , ppHidden   = dzenColor "black" "#cccccc" . pad
  675.                      , ppHiddenNoWindows = const ""
  676.                      , ppUrgent   = dzenColor "red" "yellow" . dzenStrip
  677.                      , ppWsSep    = ""
  678.                      , ppSep      = ""
  679.                      , ppLayout   = dzenColor "black" "#cccccc" .
  680.                                     (\ x -> case x of
  681.                                               "TilePrime Horizontal" -> " TTT "
  682.                                               "TilePrime Vertical"   -> " []= "
  683.                                               "Hinted Full"          -> " [ ] "
  684.                                               _                      -> pad x
  685.                                     )
  686.                      , ppTitle    = ("^bg(#324c80) " ++) . dzenEscape
  687.                      }
  688. ------------------------------------------------------------------------
  689. -- Startup hook
  690. myPlacement = inBounds (underMouse (0, 0))
  691. myStartupHook = return () >> spawn "/home/AlexYeCu/bin/autostart"
  692. main :: IO ()
  693. main=do
  694.    xmproc <- spawnPipe "~/.cabal/bin/xmobar ~/.xmobarrc"
  695.    xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig
  696.      {
  697.       focusFollowsMouse  = myFocusFollowsMouse
  698.      , borderWidth        = myBorderWidth
  699.      , modMask            = myModMask
  700.      , numlockMask        = myNumlockMask
  701.      , workspaces         = myWorkspaces
  702.      , normalBorderColor  = myNormalBorderColor
  703.      , focusedBorderColor = myFocusedBorderColor
  704.      , keys               = myKeys
  705.      , mouseBindings      = myMouseBindings
  706.      --, logHook            = myLogHookD
  707.      , logHook = do
  708.            dynamicLogWithPP $ myPP xmproc
  709.            --dynamicLogWithPP $ dzen2PP
  710.    
  711.  
  712.             --fadeInactiveLogHook 0.9
  713.  
  714.      , startupHook        = myStartupHook
  715.      , manageHook=myManageHook <+> manageDocks <+> placeHook myPlacement <+> manageMenus <+> manageDialogs <+> myManageHook2
  716.      ,layoutHook= gaps [(U,49), (R,0)] $
  717.            smartBorders $
  718.            --avoidStruts $      
  719.            mkToggle (single REFLECTX) $
  720.            --mkToggle (single REFLECTY) $
  721.            onWorkspace "sys" (maximize(minimize(windowNavigation (OneBig (3/4) (3/4) ||| mosaic 1.5 [] ||| ResizableTall 1 (3/100) (1/2) [] ||| StackTile 1 (3/100) (1/2))))) $
  722.            onWorkspace "im" (skype
  723.  ||| withIM (1%4) (Role "buddy_list") (windowNavigation ((OneBig (3/4) (3/4)))) ) $
  724.            onWorkspace "sip" (skype ||| maximize(minimize(windowNavigation (mouseResizableTileMirrored )))) $
  725.            onWorkspace "mail" (maximize(minimize(windowNavigation(mosaic 1.5 [] ||| ResizableTall 1 (3/100) (1/2) [] ||| OneBig (3/4) (3/4))))) $
  726.            onWorkspace "www" (minimize(maximize(centerMaster Grid)) ||| noBorders Full ||| maximize(minimize(windowNavigation(mosaic 1.5 [])))) $
  727.            onWorkspace "tab" ((noBorders (tabbedAlways shrinkText myTabConfig) ||| minimize(maximize(windowNavigation(OneBig (5/6) (4/5))))) ) $
  728.            onWorkspace "graph" (gimp ||| minimize(maximize(windowNavigation(OneBig (5/6) (4/5)))) ||| minimize(maximize(windowNavigation(mouseResizableTile)))) $
  729.            onWorkspace "files" (maximize(minimize(windowNavigation (mosaic 1.5 []) ||| TwoPane (3/100) (1/2) ||| Circle ||| noBorders Full))) $
  730.            onWorkspace "media" (minimize(noBorders Full ||| windowNavigation(minimize(maximize(mosaic 1.5 []))) ||| Circle ||| simplestFloat)) $
  731.            windowNavigation (maximize(minimize(windowNavigation (mosaic 1.5 [])))) ||| maximize(Circle) ||| noBorders Full ||| windowNavigation (OneBig (3/4) (3/4))
  732. }
RAW Paste Data