Advertisement
Guest User

Untitled

a guest
Mar 16th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 12.25 KB | None | 0 0
  1. import XMonad
  2. import Data.Monoid
  3. import System.Exit
  4. import XMonad.Prompt
  5. import XMonad.Prompt.Shell
  6. import XMonad.Prompt.Window
  7. import XMonad.Hooks.DynamicLog
  8. import XMonad.Hooks.ManageHelpers
  9. import XMonad.Hooks.EwmhDesktops
  10. import XMonad.Hooks.ManageDocks
  11. import XMonad.Layout.NoBorders
  12. import XMonad.Layout.Tabbed
  13. import XMonad.Layout.TwoPane
  14.  
  15. import qualified XMonad.StackSet as W
  16. import qualified Data.Map        as M
  17.  
  18. -- The preferred terminal program, which is used in a binding below and by
  19. -- certain contrib modules.
  20. --
  21. myTerminal      = "urxvtc"
  22.  
  23. -- Whether focus follows the mouse pointer.
  24. myFocusFollowsMouse :: Bool
  25. myFocusFollowsMouse = True
  26.  
  27. -- Width of the window border in pixels.
  28. --
  29. myBorderWidth   = 1
  30.  
  31. -- modMask lets you specify which modkey you want to use. The default
  32. -- is mod1Mask ("left alt").  You may also consider using mod3Mask
  33. -- ("right alt"), which does not conflict with emacs keybindings. The
  34. -- "windows key" is usually mod4Mask.
  35. --
  36. myModMask       = mod4Mask
  37.  
  38. -- The default number of workspaces (virtual screens) and their names.
  39. -- By default we use numeric strings, but any string may be used as a
  40. -- workspace name. The number of workspaces is determined by the length
  41. -- of this list.
  42. --
  43. -- A tagging example:
  44. --
  45. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  46. --
  47. myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]
  48.  
  49. -- Border colors for unfocused and focused windows, respectively.
  50. --
  51. myNormalBorderColor  = "#444444"
  52. myFocusedBorderColor = "#ff0000"
  53.  
  54. ------------------------------------------------------------------------
  55. -- Key bindings. Add, modify or remove key bindings here.
  56. --
  57. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  58.  
  59.     -- launch a terminal
  60.     [ ((modm .|. shiftMask, xK_Return ), spawn $ XMonad.terminal conf)
  61.  
  62.     -- launch shell prompt
  63.     , ((modm,               xK_p      ), shellPrompt myXPConfig)
  64.  
  65.     -- launch dmenu
  66.     , ((modm .|. shiftMask, xK_p      ), spawn "dmenu_run -b -fn '-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*' -nb '#444444' -nf '#c0c0c0' -sb '#444444' -sf '#4169e1'")
  67.  
  68.     -- close focused window
  69.     , ((modm .|. shiftMask, xK_c      ), kill)
  70.  
  71.      -- Rotate through the available layout algorithms
  72.     , ((modm,               xK_space  ), sendMessage NextLayout)
  73.  
  74.     --  Reset the layouts on the current workspace to default
  75.     , ((modm .|. shiftMask, xK_space  ), setLayout $ XMonad.layoutHook conf)
  76.  
  77.     -- Resize viewed windows to the correct size
  78.     , ((modm,               xK_n      ), refresh)
  79.  
  80.     -- Move focus to the next window
  81.     , ((modm,               xK_Tab    ), windows W.focusDown)
  82.  
  83.     -- Move focus to the next window
  84.     , ((modm,               xK_j      ), windows W.focusDown)
  85.  
  86.     -- Move focus to the previous window
  87.     , ((modm,               xK_k      ), windows W.focusUp  )
  88.  
  89.     -- Move focus to the master window
  90.     , ((modm,               xK_m      ), windows W.focusMaster  )
  91.  
  92.     -- Swap the focused window and the master window
  93.     , ((modm,               xK_Return ), windows W.swapMaster)
  94.  
  95.     -- Swap the focused window with the next window
  96.     , ((modm .|. shiftMask, xK_j      ), windows W.swapDown  )
  97.  
  98.     -- Swap the focused window with the previous window
  99.     , ((modm .|. shiftMask, xK_k      ), windows W.swapUp    )
  100.  
  101.     -- Shrink the master area
  102.     , ((modm,               xK_h      ), sendMessage Shrink)
  103.  
  104.     -- Expand the master area
  105.     , ((modm,               xK_l      ), sendMessage Expand)
  106.  
  107.     -- Push window back into tiling
  108.     , ((modm,               xK_t      ), withFocused $ windows . W.sink)
  109.  
  110.     -- Increment the number of windows in the master area
  111.     , ((modm              , xK_comma  ), sendMessage (IncMasterN 1))
  112.  
  113.     -- Deincrement the number of windows in the master area
  114.     , ((modm              , xK_period ), sendMessage (IncMasterN (-1)))
  115.  
  116.     -- Toggle the status bar gap
  117.     -- Use this binding with avoidStruts from Hooks.ManageDocks.
  118.     -- See also the statusBar function from Hooks.DynamicLog.
  119.     --
  120.     -- , ((modm              , xK_b      ), sendMessage ToggleStruts)
  121.  
  122.     -- Quit xmonad
  123.     , ((modm .|. shiftMask, xK_q      ), io (exitWith ExitSuccess))
  124.  
  125.     -- Restart xmonad
  126.     , ((modm              , xK_q      ), spawn "xmonad --recompile; xmonad --restart")
  127.    
  128.     , ((0,                  0x1008ff13), spawn "amixer set Master 1%+")
  129.     , ((0,                  0x1008ff11), spawn "amixer set Master 1%-")
  130.     , ((0,                  0x1008ff12), spawn "amixer set Master toggle")
  131.     , ((0,                  0x1008ff14), spawn "wine /home/alex/.wine/drive_c/portable/foobar2000/foobar2000.exe /playpause")
  132.     , ((0,                  0x1008ff15), spawn "wine /home/alex/.wine/drive_c/portable/foobar2000/foobar2000.exe /stop")
  133.     , ((0,                  0x1008ff16), spawn "wine /home/alex/.wine/drive_c/portable/foobar2000/foobar2000.exe /prev")
  134.     , ((0,                  0x1008ff17), spawn "wine /home/alex/.wine/drive_c/portable/foobar2000/foobar2000.exe /next")
  135.     , ((modm .|. shiftMask, xK_g      ), windowPromptGoto myXPConfig)
  136.     , ((modm .|. shiftMask, xK_b      ), windowPromptBring myXPConfig)
  137.     ]
  138.     ++
  139.  
  140.     --
  141.     -- mod-[1..9], Switch to workspace N
  142.     -- mod-shift-[1..9], Move client to workspace N
  143.     --
  144.     [((m .|. modm, k), windows $ f i)
  145.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  146.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  147.     ++
  148.  
  149.     --
  150.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  151.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  152.     --
  153.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  154.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  155.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  156.  
  157.  
  158. ------------------------------------------------------------------------
  159. -- Mouse bindings: default actions bound to mouse events
  160. --
  161. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  162.  
  163.     -- mod-button1, Set the window to floating mode and move by dragging
  164.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  165.                                        >> windows W.shiftMaster))
  166.  
  167.     -- mod-button2, Raise the window to the top of the stack
  168.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  169.  
  170.     -- mod-button3, Set the window to floating mode and resize by dragging
  171.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  172.                                        >> windows W.shiftMaster))
  173.  
  174.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  175.     ]
  176.  
  177. ------------------------------------------------------------------------
  178. -- Layouts:
  179.  
  180. -- You can specify and transform your layouts by modifying these values.
  181. -- If you change layout bindings be sure to use 'mod-shift-space' after
  182. -- restarting (with 'mod-q') to reset your layout state to the new
  183. -- defaults, as xmonad preserves your old layout settings by default.
  184. --
  185. -- The available layouts.  Note that each layout is separated by |||,
  186. -- which denotes layout choice.
  187. --
  188. myLayout = smartBorders $ avoidStruts (tiled ||| tabbedBottom shrinkText myTabConfig ||| TwoPane (1/100) (55/100) ||| Mirror tiled ||| Full)
  189.   where
  190.      -- default tiling algorithm partitions the screen into two panes
  191.      tiled   = Tall nmaster delta ratio
  192.  
  193.      -- The default number of windows in the master pane
  194.      nmaster = 1
  195.  
  196.      -- Default proportion of screen occupied by master pane
  197.      ratio   = 55/100
  198.  
  199.      -- Percent of screen to increment by when resizing panes
  200.      delta   = 1/100
  201.  
  202. ------------------------------------------------------------------------
  203. -- Window rules:
  204.  
  205. -- Execute arbitrary actions and WindowSet manipulations when managing
  206. -- a new window. You can use this to, for example, always float a
  207. -- particular program, or have a client always appear on a particular
  208. -- workspace.
  209. --
  210. -- To find the property name associated with a program, use
  211. -- > xprop | grep WM_CLASS
  212. -- and click on the client you're interested in.
  213. --
  214. -- To match on the WM_NAME, you can use 'title' in the same way that
  215. -- 'className' and 'resource' are used below.
  216. --
  217. myManageHook = manageDocks <+> composeAll
  218.     [ className =? "MPlayer"        --> doFloat
  219.     , className =? "Vlc"            --> doFloat
  220.     , className =? "Galculator"     --> doCenterFloat
  221.     , className =? "Opera"          --> doShift "1"
  222.     , appName   =? "foobar2000.exe" --> doShift "3"
  223.     , resource  =? "desktop_window" --> doIgnore
  224.     , resource  =? "kdesktop"       --> doIgnore
  225.     , className =? "Xfce4-notifyd"  --> doIgnore
  226.     , isFullscreen                  --> doFullFloat ]
  227.  
  228. ------------------------------------------------------------------------
  229. -- Event handling
  230.  
  231. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  232. --
  233. -- Defines a custom handler function for X Events. The function should
  234. -- return (All True) if the default handler is to be run afterwards. To
  235. -- combine event hooks use mappend or mconcat from Data.Monoid.
  236. --
  237. myEventHook = fullscreenEventHook <+> docksEventHook
  238.  
  239. ------------------------------------------------------------------------
  240. -- Status bars and logging
  241.  
  242. -- Perform an arbitrary action on each internal state change or X event.
  243. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  244. --
  245. myLogHook = return ()
  246.  
  247. ------------------------------------------------------------------------
  248. -- Startup hook
  249.  
  250. -- Perform an arbitrary action each time xmonad starts or is restarted
  251. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  252. -- per-workspace layout choices.
  253. --
  254. -- By default, do nothing.
  255. myStartupHook = return ()
  256.  
  257. ------------------------------------------------------------------------
  258. -- tabbed
  259. --
  260. myTabConfig = defaultTheme {
  261.         activeColor         = "#212121",
  262.         inactiveColor       = "#212121",
  263.         activeBorderColor   = "#ff0000",
  264.         inactiveBorderColor = "#444444",
  265.         activeTextColor     = "#c0c0c0",
  266.         inactiveTextColor   = "#c0c0c0",
  267.         fontName            = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*",
  268.         decoHeight          = 14
  269.     }
  270.  
  271. ------------------------------------------------------------------------
  272. -- statusbar
  273. --
  274. myBar = "xmobar"
  275. --
  276. myPP = xmobarPP {
  277.         ppCurrent = xmobarColor "#c0c0c0" "" . wrap "[" "]",
  278.         ppUrgent  = xmobarColor "#ff69b4" "" . wrap "[" "]",
  279.         ppTitle   = xmobarColor "#c0c0c0" "" . shorten 80,
  280.         ppSep     = xmobarColor "#c0c0c0" "" " | "
  281.     }
  282. --
  283. toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
  284.  
  285. ------------------------------------------------------------------------
  286. -- xp
  287. --
  288. myXPConfig = defaultXPConfig {
  289.         font              = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*",
  290.         bgColor           = "#444444",
  291.         fgColor           = "#c0c0c0",
  292.         fgHLight          = "#4169e1",
  293.         bgHLight          = "#444444",
  294.         borderColor       = "#ff0000",
  295.         promptBorderWidth = 0,
  296.         position          = Top,
  297.         height            = 14
  298.     }
  299.  
  300.  
  301. ------------------------------------------------------------------------
  302. -- Now run xmonad with all the defaults we set up.
  303.  
  304. -- Run xmonad with the settings you specify. No need to modify this.
  305. --
  306. main = xmonad =<< statusBar myBar myPP toggleStrutsKey defaults
  307.  
  308. -- A structure containing your configuration settings, overriding
  309. -- fields in the default config. Any you don't override, will
  310. -- use the defaults defined in xmonad/XMonad/Config.hs
  311. --
  312. -- No need to modify this.
  313. --
  314. defaults = ewmh defaultConfig {
  315.       -- simple stuff
  316.         terminal           = myTerminal,
  317.         focusFollowsMouse  = myFocusFollowsMouse,
  318.         borderWidth        = myBorderWidth,
  319.         modMask            = myModMask,
  320.         workspaces         = myWorkspaces,
  321.         normalBorderColor  = myNormalBorderColor,
  322.         focusedBorderColor = myFocusedBorderColor,
  323.  
  324.       -- key bindings
  325.         keys               = myKeys,
  326.         mouseBindings      = myMouseBindings,
  327.  
  328.       -- hooks, layouts
  329.         layoutHook         = myLayout,
  330.         manageHook         = myManageHook,
  331.         handleEventHook    = myEventHook,
  332.         logHook            = myLogHook,
  333.         startupHook        = myStartupHook
  334.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement