Guest User

xmonad.hs

a guest
Jul 11th, 2014
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 12.02 KB | None | 0 0
  1. --
  2. -- xmonad example config file.
  3. --
  4. -- A template showing all available configuration hooks,
  5. -- and how to override the defaults in your own xmonad.hs conf file.
  6. --
  7. -- Normally, you'd only override those defaults you care about.
  8. --
  9.  
  10. import XMonad
  11. import XMonad.Hooks.DynamicLog
  12. import XMonad.Hooks.EwmhDesktops
  13. import XMonad.Util.Run
  14. import XMonad.Hooks.ManageDocks
  15. import Data.Monoid
  16. import System.Exit
  17. import XMonad.Actions.NoBorders
  18. import XMonad.Layout.PerWorkspace
  19. import XMonad.Layout.SimplestFloat
  20. import XMonad.Layout.NoBorders
  21. import XMonad.Util.Cursor
  22. import XMonad.Layout.IM
  23. import Data.Ratio --((%))
  24. import XMonad.Layout.Grid
  25. import XMonad.Layout.Master
  26. import XMonad.Layout.LayoutCombinators hiding ( (|||) )
  27. import XMonad.Layout.Combo
  28. import XMonad.Layout.ThreeColumns
  29. import XMonad.Layout.Reflect
  30.  
  31. import qualified XMonad.StackSet as W
  32. import qualified Data.Map        as M
  33.  
  34. -- The preferred terminal program, which is used in a binding below and by
  35. -- certain contrib modules.
  36. --
  37. myTerminal      = "urxvt"
  38.  
  39. -- Whether focus follows the mouse pointer.
  40. myFocusFollowsMouse :: Bool
  41. myFocusFollowsMouse = True
  42.  
  43. -- Width of the window border in pixels.
  44. --
  45. myBorderWidth   = 1
  46.  
  47. -- modMask lets you specify which modkey you want to use. The default
  48. -- is mod1Mask ("left alt").  You may also consider using mod3Mask
  49. -- ("right alt"), which does not conflict with emacs keybindings. The
  50. -- "windows key" is usually mod4Mask.
  51. --
  52. myModMask       = mod4Mask
  53.  
  54. -- The default number of workspaces (virtual screens) and their names.
  55. -- By default we use numeric strings, but any string may be used as a
  56. -- workspace name. The number of workspaces is determined by the length
  57. -- of this list.
  58. --
  59. -- A tagging example:
  60. --
  61. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  62. --
  63. myWorkspaces    = ["main","web","code","play","IM","any","float","books","other"]
  64.  
  65.  
  66. -- Border colors for unfocused and focused windows, respectively.
  67. --
  68. myNormalBorderColor  = "#dddddd"
  69. myFocusedBorderColor = "#ff0000"
  70.  
  71. ------------------------------------------------------------------------
  72. -- Key bindings. Add, modify or remove key bindings here.
  73. --
  74. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  75.  
  76.     -- launch a terminal
  77.     [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  78.  
  79.     -- launch dmenu
  80.     , ((modm,               xK_p     ), spawn "dmenu_run")
  81.  
  82.     -- launch deadbeef
  83.     --, ((modm .|. shiftMask, xK_p     ), spawn "dmenu_run")
  84.  
  85.     -- launch firefox
  86.     , ((modm,               xK_z     ), spawn "firefox")
  87.  
  88.     -- launch shutdown
  89.     , ((modm,               xK_Escape), spawn "sudo /sbin/poweroff")
  90.  
  91.     -- launch reboot
  92.     , ((modm .|. shiftMask, xK_Escape), spawn "sudo /sbin/reboot")
  93.  
  94.     -- launch skype
  95.     , ((modm,               xK_s     ), spawn "skype")
  96.    
  97.     -- launch torrent-client
  98.     , ((modm,               xK_x     ), spawn "transmission-gtk")
  99.    
  100.     -- launch FBReader
  101.     --, ((modm,               xK_a     ), spawn "FBReader")
  102.  
  103.     -- launch file manager
  104.     , ((modm,               xK_f     ), spawn "nautilus")
  105.  
  106.     -- launch lock
  107.     , ((mod1Mask,           xK_F4    ), spawn "slock & xset dpms force off")
  108.  
  109.     -- launch lock
  110.     , ((0,            xK_Print       ), spawn "scrot ~/Pictures/'%Y-%m-%d-%T_$wx$h_scrot.png'")
  111.  
  112.     -- NoBorders   
  113.     , ((modm,               xK_g     ), withFocused toggleBorder)
  114.  
  115.     -- close focused window
  116.     , ((modm .|. shiftMask, xK_c     ), kill)
  117.  
  118.      -- Rotate through the available layout algorithms
  119.     , ((modm,               xK_space ), sendMessage NextLayout)
  120.  
  121.     --  Reset the layouts on the current workspace to default
  122.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  123.  
  124.     -- Resize viewed windows to the correct size
  125.     , ((modm,               xK_n     ), refresh)
  126.  
  127.     -- Move focus to the next window
  128.     , ((modm,               xK_Tab   ), windows W.focusDown)
  129.  
  130.     -- Move focus to the next window
  131.     , ((modm,               xK_j     ), windows W.focusDown)
  132.  
  133.     -- Move focus to the previous window
  134.     , ((modm,               xK_k     ), windows W.focusUp  )
  135.  
  136.     -- Move focus to the master window
  137.     , ((modm,               xK_m     ), windows W.focusMaster  )
  138.  
  139.     -- Swap the focused window and the master window
  140.     , ((modm,               xK_Return), windows W.swapMaster)
  141.  
  142.     -- Swap the focused window with the next window
  143.     , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
  144.  
  145.     -- Swap the focused window with the previous window
  146.     , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
  147.  
  148.     -- Shrink the master area
  149.     , ((modm,               xK_h     ), sendMessage Shrink)
  150.  
  151.     -- Expand the master area
  152.     , ((modm,               xK_l     ), sendMessage Expand)
  153.  
  154.     -- Push window back into tiling
  155.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  156.  
  157.     -- Increment the number of windows in the master area
  158.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  159.  
  160.     -- Deincrement the number of windows in the master area
  161.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  162.  
  163.     -- Toggle the status bar gap
  164.     -- Use this binding with avoidStruts from Hooks.ManageDocks.
  165.     -- See also the statusBar function from Hooks.DynamicLog.
  166.     --
  167.     , ((modm              , xK_b     ), sendMessage ToggleStruts)
  168.  
  169.     -- Quit xmonad
  170.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  171.  
  172.     -- Restart xmonad
  173.     , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  174.     ]
  175.     ++
  176.  
  177.     --
  178.     -- mod-[1..9], Switch to workspace N
  179.     -- mod-shift-[1..9], Move client to workspace N
  180.     --
  181.     [((m .|. modm, k), windows $ f i)
  182.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  183.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  184.     ++
  185.  
  186.     --
  187.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  188.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  189.     --
  190.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  191.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  192.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  193.  
  194.  
  195. ------------------------------------------------------------------------
  196. -- Mouse bindings: default actions bound to mouse events
  197. --
  198. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  199.  
  200.     -- mod-button1, Set the window to floating mode and move by dragging
  201.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  202.                                        >> windows W.shiftMaster))
  203.  
  204.     -- mod-button2, Raise the window to the top of the stack
  205.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  206.  
  207.     -- mod-button3, Set the window to floating mode and resize by dragging
  208.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  209.                                        >> windows W.shiftMaster))
  210.  
  211.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  212.     ]
  213.  
  214. ------------------------------------------------------------------------
  215. -- Layouts:
  216.  
  217. -- You can specify and transform your layouts by modifying these values.
  218. -- If you change layout bindings be sure to use 'mod-shift-space' after
  219. -- restarting (with 'mod-q') to reset your layout state to the new
  220. -- defaults, as xmonad preserves your old layout settings by default.
  221. --
  222. -- The available layouts.  Note that each layout is separated by |||,
  223. -- which denotes layout choice.
  224. --
  225.  
  226. myLayout =
  227.     onWorkspaces ["web","books","other"] ( Full ||| tiled ||| Mirror tiled ) $
  228.     onWorkspace "IM" ( reflectHoriz $ withIM (1%11) (Title "prevedddd - Skype™") Grid ) $
  229.     onWorkspace "float" simplestFloat $
  230.     onWorkspaces ["main","code","play","any"] ( tiled ||| Mirror tiled ||| Full ) $
  231.     tiled
  232.     where
  233.         tiled = Tall nmaster delta ratio
  234.         -- The default number of windows in the master pane
  235.         nmaster = 1
  236.         -- Default proportion of screen occupied by master pane
  237.         ratio   = 1/2
  238.         -- Percent of screen to increment by when resizing panes
  239.         delta   = 3/100
  240.  
  241.  
  242. ------------------------------------------------------------------------
  243. -- Window rules:
  244.  
  245. -- Execute arbitrary actions and WindowSet manipulations when managing
  246. -- a new window. You can use this to, for example, always float a
  247. -- particular program, or have a client always appear on a particular
  248. -- workspace.
  249. --
  250. -- To find the property name associated with a program, use
  251. -- > xprop | grep WM_CLASS
  252. -- and click on the client you're interested in.
  253. --
  254. -- To match on the WM_NAME, you can use 'title' in the same way that
  255. -- 'className' and 'resource' are used below.
  256. --
  257.  
  258. myManageHook = composeAll
  259.     [ className =? "MPlayer"                --> doFloat
  260.     , className =? "Totem"                  --> doFloat
  261. --    , className =? "Steam"                --> doFloat
  262.     , title     =? "Skype™ 4.2 for Linux"   --> doIgnore
  263.     , resource  =? "trayer"                 --> doIgnore
  264.     , className =? "Xfce4-notifyd"          --> doIgnore
  265.     , className =? "Wrapper"                --> doIgnore
  266.     , className =? "Firefox"                --> doF (W.shift "web")
  267.     , className =? "FBReader"               --> doF (W.shift "books")
  268.     , className =? "Thunderbird"            --> doF (W.shift "other")
  269.     , className =? "Rhythmbox"              --> doF (W.shift "play")
  270. --    , appName   =? "Places"               --> doF (W.shift "main")
  271.     , className =? "Gimp"                   --> doF (W.shift "float")
  272.     , className =? "Skype"                  --> doF (W.shift "IM")
  273.     , className =? "Empathy"                --> doF (W.shift "IM") ]
  274.  
  275.  
  276. ------------------------------------------------------------------------
  277. -- Event handling
  278.  
  279. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  280. --
  281. -- Defines a custom handler function for X Events. The function should
  282. -- return (All True) if the default handler is to be run afterwards. To
  283. -- combine event hooks use mappend or mconcat from Data.Monoid.
  284. --
  285. myEventHook = mempty
  286.  
  287. ------------------------------------------------------------------------
  288. -- Status bars and logging
  289.  
  290. -- Perform an arbitrary action on each internal state change or X event.
  291. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  292. --
  293. myLogHook h = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn h }
  294.     where
  295.         xmobarPP = defaultPP { 
  296.               ppCurrent         = xmobarColor "#CC3333" "" . wrap "[" "]"
  297.             , ppHidden          = xmobarColor "#429942" ""
  298.             , ppHiddenNoWindows = xmobarColor "#ffffff" ""
  299.             , ppTitle           = \_ -> ""
  300.     }
  301.  
  302. ------------------------------------------------------------------------
  303. -- Startup hook
  304.  
  305. -- Perform an arbitrary action each time xmonad starts or is restarted
  306. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  307. -- per-workspace layout choices.
  308. --
  309. -- By default, do nothing.
  310. myStartupHook = setDefaultCursor xC_left_ptr -- return ()
  311.  
  312. ------------------------------------------------------------------------
  313. -- Now run xmonad with all the defaults we set up.
  314.  
  315. -- Run xmonad with the settings you specify. No need to modify this.
  316. --
  317. main = do
  318.     h <- spawnPipe  "xmobar"
  319.  
  320. -- A structure containing your configuration settings, overriding
  321. -- fields in the default config. Any you don't override, will
  322. -- use the defaults defined in xmonad/XMonad/Config.hs
  323. --
  324. -- No need to modify this.
  325. --
  326.     xmonad $ ewmh  defaultConfig {
  327.       -- simple stuff
  328.           terminal           = myTerminal
  329.         , focusFollowsMouse  = myFocusFollowsMouse
  330.         , borderWidth        = myBorderWidth
  331.         , modMask            = myModMask
  332.         , workspaces         = myWorkspaces
  333.         , normalBorderColor  = myNormalBorderColor
  334.         , focusedBorderColor = myFocusedBorderColor
  335.  
  336.       -- key bindings
  337.         , keys               = myKeys
  338.         , mouseBindings      = myMouseBindings
  339.  
  340.       -- hooks, layouts
  341.         , layoutHook         = smartBorders $ avoidStruts myLayout
  342.         , manageHook         = myManageHook <+> manageDocks
  343.         , handleEventHook    = myEventHook <+> fullscreenEventHook
  344.         , logHook            = myLogHook h
  345.         , startupHook        = myStartupHook
  346.     }
Advertisement
Add Comment
Please, Sign In to add comment