Advertisement
Guest User

Untitled

a guest
Jun 10th, 2010
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 13.41 KB | None | 0 0
  1. --
  2. -- xmonad config file.
  3. --
  4.  
  5. import XMonad
  6. import List
  7. import Data.Monoid
  8. import System.Exit
  9. import System.IO
  10.  
  11. import qualified XMonad.StackSet as W
  12. import qualified Data.Map        as M
  13.  
  14. -- Layout stuff
  15. import XMonad.Layout.NoBorders
  16. import XMonad.Layout.IM
  17. import XMonad.Layout.PerWorkspace
  18. import XMonad.Layout.ResizableTile
  19. import XMonad.Layout.Reflect
  20.  
  21. -- Hooks
  22. import XMonad.Hooks.DynamicLog
  23. import XMonad.Hooks.EwmhDesktops
  24. import XMonad.Hooks.ManageDocks
  25. import XMonad.Hooks.SetWMName
  26. import XMonad.Hooks.UrgencyHook
  27.  
  28. -- Utils
  29. import XMonad.Util.Loggers
  30. import XMonad.Util.Run
  31. import XMonad.Util.WorkspaceCompare
  32.  
  33.  
  34.  
  35. myTerminal      = "urxvtc"
  36.  
  37. myModMask       = mod4Mask
  38.  
  39. -- The mask for the numlock key. Numlock status is "masked" from the
  40. -- current modifier status, so the keybindings will work with numlock on or
  41. -- off. You may need to change this on some systems.
  42. --
  43. -- Set numlockMask = 0 if you don't have a numlock key, or want to treat
  44. -- numlock status separately.
  45. --
  46. myNumlockMask   = mod2Mask
  47.  
  48. -- in Db!
  49. myVolStep = "1"
  50.  
  51. -- A tagging example:
  52. --
  53. myWorkspaces    = ["一","二","三","四","五","六","七","八","九"]
  54.  
  55. -- Border colors for unfocused and focused windows, respectively.
  56. --
  57. myNormalBorderColor  = "#000000"
  58. myFocusedBorderColor = "#ffffff"
  59.  
  60. ------------------------------------------------------------------------
  61. -- Layouts:
  62.  
  63. -- You can specify and transform your layouts by modifying these values.
  64. -- If you change layout bindings be sure to use 'mod-shift-space' after
  65. -- restarting (with 'mod-q') to reset your layout state to the new
  66. -- defaults, as xmonad preserves your old layout settings by default.
  67. --
  68. -- smartBorders removes borders when floated window is fullscreen or when
  69. -- there's only one window on a screen.
  70. --
  71. -- avoidStruts leaves enough space for docks wherever they appear.
  72. --
  73. myLayout = avoidStruts $ smartBorders $ onWorkspace "六" gimpLayout $ standardLayouts
  74.   where
  75.      -- default tiling algorithm partitions the screen into two panes
  76.      tiled   = ResizableTall nmaster delta ratio slaves
  77.  
  78.      -- The default number of windows in the master pane
  79.      nmaster = 1
  80.  
  81.      -- Default proportion of screen occupied by master pane
  82.      ratio   = 1/2
  83.  
  84.      -- Percent of screen to increment by when resizing panes
  85.      delta   = 3/100
  86.  
  87.      --
  88.      slaves  = []
  89.  
  90.      --
  91.      gimpLayout = withIM (0.11) (Role "gimp-toolbox") $
  92.          reflectHoriz $
  93.          withIM (0.15) (Role "gimp-dock") standardLayouts
  94.    
  95.  
  96.      standardLayouts = tiled ||| Mirror tiled ||| Full
  97.  
  98. ------------------------------------------------------------------------
  99. -- Window rules:
  100.  
  101. -- Execute arbitrary actions and WindowSet manipulations when managing
  102. -- a new window. You can use this to, for example, always float a
  103. -- particular program, or have a client always appear on a particular
  104. -- workspace.
  105. --
  106. -- To find the property name associated with a program, use
  107. -- > xprop | grep WM_CLASS
  108. -- and click on the client you're interested in.
  109. --
  110. -- To match on the WM_NAME, you can use 'title' in the same way that
  111. -- 'className' and 'resource' are used below.
  112. --
  113. -- manageDocks de-manages dock windows, so xmonad does not try to
  114. -- tile them
  115. --
  116. myManageHook = composeAll
  117.     [ className =? "MPlayer"        --> doFloat <+> doShift "四"
  118.     , className =? "feh"            --> doFloat
  119.     , className =? "Ario"           --> doShift "四"
  120.     , className =? "Ossxmix"        --> doShift "四"
  121.     , className =? "Galculator"     --> doFloat
  122.     , className =? "Firefox"        --> doShift "一"
  123.     , className =? "Gimp"           --> doShift "六"
  124.     ]
  125.  
  126. ------------------------------------------------------------------------
  127. -- Event handling
  128.  
  129. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  130. --
  131. -- Defines a custom handler function for X Events. The function should
  132. -- return (All True) if the default handler is to be run afterwards. To
  133. -- combine event hooks use mappend or mconcat from Data.Monoid.
  134. --
  135. myEventHook = mempty
  136.  
  137. ------------------------------------------------------------------------
  138. -- Status bars and logging
  139.  
  140. -- Perform an arbitrary action on each internal state change or X event.
  141. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  142. --
  143. -- General status bar options
  144. myStatusBar = "dzen2 -w 800 -ta l " ++ myDzenGenOpts
  145. -- General dzen options
  146. myDzenGenOpts = "-fg '" ++ myGeneralFgColor ++ "' -bg '" ++ myGeneralBgColor ++ "' -fn '" ++ myFont ++ "'"
  147.  
  148. -- Icons
  149. myIconPath = "/home/runiq/.config/dzen2/icons/"
  150.  
  151. -- Fonts
  152. mySymbolFont = "DejaVu Sans-9"
  153. myFont = "Meguri P-9:bold"
  154. myJapaneseFont = "Meguri P-14:bold"
  155.  
  156. -- Colors
  157. myGeneralFgColor = "#ffffff"
  158. myGeneralBgColor = "#000000"
  159. myCurrentFgColor = "#ffffff"
  160. myCurrentBgColor = "#000000"
  161. myVisibleFgColor = "#1994d1"
  162. myVisibleBgColor = "#000000"
  163. myHiddenFgColor  = "#1550aa"
  164. myHiddenBgColor  = "#000000"
  165. myHiddenNWFgColor = "#888888"
  166. myHiddenNWBgColor = "#000000"
  167. myUrgentFgColor  = "#ff0000"
  168. myUrgentBgColor  = "#000000"
  169. myTitleFgColor = "#ffffff"
  170. myTitleBgColor = "#000000"
  171. myLayoutFgColor = "#1994d1"
  172. myLayoutBgColor = "#000000"
  173. mySep = " "
  174. myWsSep = " "
  175.  
  176.  
  177. myPP = dzenPP
  178.     { ppCurrent = wrapFont myJapaneseFont . dzenColor myCurrentFgColor myCurrentBgColor
  179.     , ppVisible = wrapFont myJapaneseFont . dzenColor myVisibleFgColor myVisibleBgColor . wrapClickable
  180.     , ppHidden = wrapFont myJapaneseFont . dzenColor myHiddenFgColor myHiddenBgColor
  181.     -- , ppHiddenNoWindows = const "" -- not needed
  182.     , ppUrgent = wrapFont myJapaneseFont . dzenColor myUrgentFgColor myUrgentBgColor . dzenStrip
  183.     , ppSep = mySep
  184.     , ppWsSep = myWsSep
  185.     , ppTitle = dzenColor myTitleFgColor myTitleBgColor . shorten 50
  186.     , ppLayout = dzenColor myLayoutFgColor"" .
  187.         (\x -> case x of
  188.             "ResizableTall" -> wrapBitmap "dzen_bitmaps/tall.xbm"
  189.             "Mirror ResizableTall" -> wrapBitmap "dzen_bitmaps/mtall.xbm"
  190.             "Full" -> wrapBitmap "dzen_bitmaps/full.xbm"
  191.  
  192.             "IM ReflectX IM ResizableTall" -> wrapBitmap "dzen_bitmaps/tall.xbm"
  193.             "IM ReflectX IM Mirror ResizableTall" -> wrapBitmap "dzen_bitmaps/mtall.xbm"
  194.             "IM ReflectX IM Full" -> wrapBitmap "dzen_bitmaps/full.xbm")
  195.     -- , ppOutput = hPutStrLn h
  196.     }
  197.     where
  198.          currentWsIndex w = case (elemIndex w myWorkspaces) of
  199.                                  Nothing -> "1"
  200.                          Just n -> show n
  201.         wrapClickable content = wrap ("^ca(1,xdotool key super+" ++ (show $ currentWsIndex content)) "^ca()"
  202.         wrapFont font = wrap ("^fn(" ++ font ++ ")") "^fn()"
  203.         wrapBitmap bitmap = "^p(5)^i(" ++ myIconPath ++ bitmap ++ ")^p(5)"
  204.  
  205. ------------------------------------------------------------------------
  206. -- Startup hook
  207.  
  208. -- By default, do nothing.
  209. --myStartupHook = return ()
  210. --
  211. -- Set WMName to LG3D for Java apps
  212. myStartupHook = setWMName "LG3D"
  213.  
  214. ------------------------------------------------------------------------
  215. -- Key bindings. Add, modify or remove key bindings here.
  216. --
  217. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  218.  
  219.     -- launch a terminal
  220.     [ ((modm,               xK_y     ), spawn $ XMonad.terminal conf)
  221.  
  222.     -- launch dmenu
  223.     , ((modm,               xK_x     ), spawn "exe=`dmenu_path | dmenu -i -r -p \"Execute:\" -y 0 -w 1032 -nb black -nf \"#103060\" -sb black -sf \"#1d53ff\" -fn \"xft:DejaVu Sans-9:Condensed\"` && eval \"exec $exe\"")
  224.  
  225.     -- close focused window
  226.     , ((modm .|. shiftMask, xK_c     ), kill)
  227.  
  228.      -- Rotate through the available layout algorithms
  229.     , ((modm,               xK_space ), sendMessage NextLayout)
  230.  
  231.     --  Reset the layouts on the current workspace to default
  232.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  233.  
  234.     -- Resize viewed windows to the correct size
  235.     , ((modm,               xK_n     ), refresh)
  236.  
  237.     -- Move focus to the next window
  238.     , ((modm,               xK_j     ), windows W.focusDown)
  239.  
  240.     -- Move focus to the previous window
  241.     , ((modm,               xK_k     ), windows W.focusUp  )
  242.  
  243.     -- Move focus to the master window
  244.     , ((modm,               xK_m     ), windows W.focusMaster  )
  245.  
  246.     -- Swap the focused window and the master window
  247.     , ((modm,               xK_Return), windows W.swapMaster)
  248.  
  249.     -- Swap the focused window with the next window
  250.     , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
  251.  
  252.     -- Swap the focused window with the previous window
  253.     , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
  254.  
  255.     -- Shrink the master area
  256.     , ((modm,               xK_h     ), sendMessage Shrink)
  257.  
  258.     -- Expand the master area
  259.     , ((modm,               xK_l     ), sendMessage Expand)
  260.  
  261.     -- Push window back into tiling
  262.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  263.  
  264.     -- Increment the number of windows in the master area
  265.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  266.  
  267.     -- Deincrement the number of windows in the master area
  268.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  269.  
  270.     -- Toggle the status bar gap
  271.     -- Use this binding with avoidStruts from Hooks.ManageDocks.
  272.     -- See also the statusBar function from Hooks.DynamicLog.
  273.     --
  274.     -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
  275.  
  276.     -- Quit xmonad
  277.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  278.  
  279.     -- Restart xmonad
  280.     , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  281.  
  282.     ------------------------------------------------------------------------------------
  283.     -- my own keybindings
  284.     --
  285.     -- Control MPD
  286.     , ((modm              , xK_Left   ), spawn "mpc prev")
  287.     , ((modm              , xK_Right  ), spawn "mpc next")
  288.     , ((modm              , xK_Down   ), spawn "mpc toggle")
  289.     , ((modm              , xK_Up     ), spawn "mpc random")
  290.  
  291.     -- The following are XF86* keybindings, I looked them up in
  292.     -- /usr/include/X11/XF86keysym.h.  
  293.     --
  294.     -- I tend to hit both the Fn and the Super key, so here goes nothing
  295.     --
  296.     -- Toggle between Mute and non-mute
  297.     , ((0                 , 0x1008FF12), spawn "ossmix misc.front-mute toggle")
  298.     , ((modm              , xK_F3     ), spawn "ossmix misc.front-mute toggle")
  299.  
  300.     -- Lower volume by <myVolStep> Db
  301.     , ((0                 , 0x1008FF11), spawn ("ossmix vmix0-outvol -- -" ++ myVolStep))
  302.     , ((modm              , xK_F4     ), spawn ("ossmix vmix0-outvol -- -" ++ myVolStep))
  303.  
  304.     -- Raise volume by <myVolStep> Db
  305.     , ((0                 , 0x1008FF13), spawn ("ossmix vmix0-outvol -- +" ++ myVolStep))
  306.     , ((modm              , xK_F5     ), spawn ("ossmix vmix0-outvol -- +" ++ myVolStep))
  307.  
  308.     -- Shrink slave windows
  309.     , ((modm              , xK_a      ), sendMessage MirrorShrink)
  310.    
  311.     -- Expand slave windows
  312.     , ((modm              , xK_s      ), sendMessage MirrorExpand)
  313.     ]
  314.     ++
  315.  
  316.     --
  317.     -- mod-[1..9], Switch to workspace N
  318.     -- mod-shift-[1..9], Move client to workspace N
  319.     --
  320.     [((m .|. modm, k), windows $ f i)
  321.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  322.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  323.     ++
  324.  
  325.     --
  326.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  327.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  328.     --
  329.     -- Kein greedyView --> kein Swap der Workspaces
  330.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  331.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  332.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  333.  
  334. ------------------------------------------------------------------------
  335. -- Mouse bindings: default actions bound to mouse events
  336. --
  337. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  338.  
  339.     -- mod-button1, Set the window to floating mode and move by dragging
  340.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  341.                                        >> windows W.shiftMaster))
  342.  
  343.     -- mod-button2, Raise the window to the top of the stack
  344.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  345.  
  346.     -- mod-button3, Set the window to floating mode and resize by dragging
  347.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  348.                                        >> windows W.shiftMaster))
  349.  
  350.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  351.     ]
  352.  
  353. ------------------------------------------------------------------------
  354. -- Now run xmonad with all the defaults we set up.
  355.  
  356. main = do
  357.  
  358.     -- Spawns dzen as specified in myStatusBar
  359.     --
  360.     myStatusBarPipe <- spawnPipe myStatusBar
  361.     xmonad  $ withUrgencyHook NoUrgencyHook $ ewmh defaultConfig {
  362.       -- simple stuff
  363.         terminal           = myTerminal,
  364.         modMask            = myModMask,
  365.         numlockMask        = myNumlockMask,
  366.         workspaces         = myWorkspaces,
  367.         normalBorderColor  = myNormalBorderColor,
  368.         focusedBorderColor = myFocusedBorderColor,
  369.  
  370.       -- key bindings
  371.         keys               = myKeys,
  372.         mouseBindings      = myMouseBindings,
  373.  
  374.       -- hooks, layouts
  375.         layoutHook         = myLayout,
  376.         manageHook         = myManageHook,
  377.         handleEventHook    = myEventHook,
  378.       -- why can't I run this from myLogHook :-(
  379.         logHook            = dynamicLogWithPP $ myPP myStatusBarPipe,
  380.         startupHook        = myStartupHook
  381.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement