Advertisement
Guest User

xmonad.hs

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