xmonad.hs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. -- My XMonad config file
  2. import XMonad
  3. import Data.Monoid
  4. import System.Exit
  5. -- import XMonad.Actions.CycleRecentWS -- I don't understand how to configure this
  6. import XMonad.Actions.CycleWS
  7. import XMonad.Actions.DynamicWorkspaces
  8. import XMonad.Actions.SwapWorkspaces
  9. import XMonad.Layout.ShowWName
  10. import XMonad.Layout.ThreeColumns
  11. import XMonad.Layout.Minimize
  12. import XMonad.Prompt (defaultXPConfig, XPConfig(..), XPPosition(Top))
  13. import qualified XMonad.StackSet as W
  14. import qualified Data.Map as M
  15. -- The preferred terminal program, which is used in a binding below and by
  16. -- certain contrib modules.
  17. --
  18. myTerminal = "lxterminal"
  19. -- xterm -u8 -ls -fg lightgreen -bg black"
  20. -- -fg white -bg black"
  21. -- -fa 'Misc' -fs 10"
  22. -- Whether focus follows the mouse pointer.
  23. myFocusFollowsMouse :: Bool
  24. myFocusFollowsMouse = True
  25. -- Whether clicking on a window to focus also passes the click to the window
  26. myClickJustFocuses :: Bool
  27. myClickJustFocuses = False
  28. myPrompt :: XPConfig
  29. myPrompt = defaultXPConfig {
  30. position = Top
  31. , font = "xft:Consolas-14"
  32. , height = 24
  33. -- Zenburn!:
  34. , bgColor = "#3F3F3F"
  35. , fgColor = "#EFEFEF"
  36. , fgHLight = "#000D18"
  37. , bgHLight = "#8FAF9F"
  38. , borderColor = "#719E7F"
  39. }
  40. -- Width of the window border in pixels.
  41. myBorderWidth = 1
  42. -- modMask lets you specify which modkey you want to use. The default
  43. -- is mod1Mask ("left alt"). You may also consider using mod3Mask
  44. -- ("right alt"), which does not conflict with emacs keybindings. The
  45. -- "windows key" is usually mod4Mask.
  46. --
  47. myModMask = mod1Mask
  48. -- myModMask = mod4Mask
  49. -- the obvious choice is windows key (window manager)! plus alt is not ergonomic on my kbd.
  50. -- The default number of workspaces (virtual screens) and their names.
  51. -- By default we use numeric strings, but any string may be used as a
  52. -- workspace name. The number of workspaces is determined by the length
  53. -- of this list.
  54. --
  55. -- A tagging example:
  56. --
  57. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  58. --
  59. myWorkspaces = ["0", "1","2","3","4","5","6","7","8","9"]
  60. -- Border colors for unfocused and focused windows, respectively.
  61. myNormalBorderColor = "#aaaaaa"
  62. myFocusedBorderColor = "#0000ff"
  63. ------------------------------------------------------------------------
  64. -- Key bindings. Add, modify or remove key bindings here.
  65. --
  66. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  67. -- launch a terminal
  68. [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  69. -- ?
  70. -- , ((modm, xK_p ), spawn "dmenu_run")
  71. -- , ((modm .|. shiftMask, xK_p ), spawn "gmrun")
  72. -- , ((modm, 0x1008ff03), spawn "sudo brightness -")
  73. -- , ((modm, 0x1008ff02), spawn "sudo brightness +")
  74. , ((modm, xK_F1), spawn "light -U 10")
  75. , ((modm, xK_F2), spawn "light -A 10")
  76. -- close focused window
  77. , ((modm .|. shiftMask, xK_c ), kill)
  78. -- Rotate through the available layout algorithms
  79. , ((modm, xK_space ), sendMessage NextLayout)
  80. -- Reset the layouts on the current workspace to default
  81. , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  82. -- , ((modm, xK_m ), withFocused minimizeWindow)
  83. -- , ((modm .|. shiftMask, xK_m ), sendMessage RestoreNextMinimizedWin)
  84. -- Resize viewed windows to the correct size
  85. , ((modm, xK_n ), refresh)
  86. -- Move focus to the next window
  87. , ((modm, xK_Tab ), windows W.focusDown)
  88. -- Move focus to the previous window
  89. , ((modm .|. shiftMask, xK_Tab ), windows W.focusUp)
  90. -- Move focus to the next window (bis)
  91. -- depending on keyboard, more ergonomic mapping
  92. , ((mod1Mask, xK_Tab ), windows W.focusDown)
  93. -- Move focus to the previous window (bis)
  94. , ((mod1Mask .|. shiftMask, xK_Tab ), windows W.focusUp)
  95. -- Move focus to the next window
  96. , ((modm, xK_j ), windows W.focusDown)
  97. -- Move focus to the previous window
  98. , ((modm, xK_k ), windows W.focusUp )
  99. -- Move focus to the master window
  100. , ((modm, xK_m ), windows W.focusMaster )
  101. -- Swap the focused window and the master window
  102. , ((modm, xK_Return), windows W.swapMaster)
  103. -- Swap the focused window with the next window
  104. , ((modm .|. shiftMask, xK_j ), windows W.swapDown )
  105. -- Swap the focused window with the previous window
  106. , ((modm .|. shiftMask, xK_k ), windows W.swapUp )
  107. -- Shrink the master area
  108. , ((modm, xK_h ), sendMessage Shrink)
  109. -- Expand the master area
  110. , ((modm, xK_l ), sendMessage Expand)
  111. -- Push window back into tiling
  112. , ((modm, xK_t ), withFocused $ windows . W.sink)
  113. -- Increment the number of windows in the master area
  114. , ((modm , xK_comma ), sendMessage (IncMasterN 1))
  115. -- Deincrement the number of windows in the master area
  116. , ((modm , xK_period), sendMessage (IncMasterN (-1)))
  117. -- Toggle the status bar gap
  118. -- Use this binding with avoidStruts from Hooks.ManageDocks.
  119. -- See also the statusBar function from Hooks.DynamicLog.
  120. --
  121. -- , ((modm , xK_b ), sendMessage ToggleStruts)
  122. -- Quit xmonad -- NO!
  123. -- , ((modm .|. shiftMask .|. mod2Mask .|. mod3Mask, xK_q ), io (exitWith ExitSuccess))
  124. -- , ((modm .|. shiftMask , xK_s ), spawn " slock & (sleep 1 ; sudo su -c \"echo mem > /sys/power/state\")" )
  125. , ((modm .|. shiftMask , xK_s ), spawn " slock " )
  126. -- , ((modm .|. shiftMask , xK_x ), spawn "sudo su -c \"echo mem > /sys/power/state\"" )
  127. -- "slock")
  128. -- perfect!
  129. , ((modm, xK_Escape), spawn "scrot -e 'mv $f ~/Screenshots'" )
  130. -- Restart xmonad
  131. , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
  132. , ((modm .|. shiftMask , xK_q ), spawn "emacs ~/.xmonad/xmonad.hs")
  133. , ((modm , xK_n), addWorkspacePrompt myPrompt)
  134. , ((modm .|. shiftMask , xK_n), removeEmptyWorkspace)
  135. -- Cycle
  136. -- , ((), cycleRecentWS [] )
  137. , ((modm , xK_Left), prevWS)
  138. , ((modm , xK_Right), nextWS)
  139. , ((modm .|. shiftMask , xK_Left), shiftToPrev)
  140. , ((modm .|. shiftMask , xK_Right), shiftToNext)
  141. , ((modm , xK_Up), prevScreen)
  142. , ((modm , xK_Down), nextScreen)
  143. , ((modm .|. shiftMask , xK_Up), shiftPrevScreen)
  144. , ((modm .|. shiftMask , xK_Down), shiftNextScreen)
  145. -- Run xmessage with a summary of the default keybindings (useful for beginners)
  146. -- help not found
  147. -- , ((modMask .|. shiftMask, xK_slash ), spawn ("echo \"" ++ help ++ "\" | xmessage -file -"))
  148. ]
  149. ++
  150. --
  151. -- mod-[0..9], Switch to workspace N
  152. -- mod-shift-[0..9], Move client to workspace N
  153. --
  154. [((m .|. modm, k), windows $ f i)
  155. | (i, k) <- zip (XMonad.workspaces conf) [xK_0 .. xK_9]
  156. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  157. -- mod-ctrl-[0..9], swap
  158. ++
  159. [((modm .|. controlMask, k), windows $ swapWithCurrent i)
  160. | (i, k) <- zip (XMonad.workspaces conf) [xK_0 ..]]
  161. ++
  162. --
  163. -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  164. -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  165. --
  166. [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  167. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  168. , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  169. ------------------------------------------------------------------------
  170. -- Mouse bindings: default actions bound to mouse events
  171. --
  172. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  173. -- mod-button1, Set the window to floating mode and move by dragging
  174. [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  175. >> windows W.shiftMaster))
  176. -- had to swap these
  177. -- -- mod-button2, Raise the window to the top of the stack
  178. -- , ((modm, button3), (\w -> focus w >> windows W.shiftMaster))
  179. --
  180. -- this causes fucking freeze
  181. -- mod-button3, Set the window to floating mode and resize by dragging
  182. , ((modm, button2), (\w -> focus w >> mouseResizeWindow w
  183. >> windows W.shiftMaster))
  184. -- mod-button3, Set the window to floating mode and resize by dragging
  185. , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  186. >> windows W.shiftMaster))
  187. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  188. ]
  189. ------------------------------------------------------------------------
  190. -- Layouts:
  191. -- You can specify and transform your layouts by modifying these values.
  192. -- If you change layout bindings be sure to use 'mod-shift-space' after
  193. -- restarting (with 'mod-q') to reset your layout state to the new
  194. -- defaults, as xmonad preserves your old layout settings by default.
  195. --
  196. -- The available layouts. Note that each layout is separated by |||,
  197. -- which denotes layout choice.
  198. --
  199. myLayout = minimize ( tiled ||| Mirror tiled ||| Full ||| threecol )
  200. where
  201. -- default tiling algorithm partitions the screen into two panes
  202. tiled = Tall nmaster delta ratio
  203. -- The default number of windows in the master pane
  204. nmaster = 1
  205. -- Default proportion of screen occupied by master pane
  206. ratio = 1/2
  207. -- Percent of screen to increment by when resizing panes
  208. delta = 3/100
  209. threecol = ThreeCol nmaster delta ratio
  210. ------------------------------------------------------------------------
  211. -- Window rules:
  212. -- Execute arbitrary actions and WindowSet manipulations when managing
  213. -- a new window. You can use this to, for example, always float a
  214. -- particular program, or have a client always appear on a particular
  215. -- workspace.
  216. --
  217. -- To find the property name associated with a program, use
  218. -- > xprop | grep WM_CLASS
  219. -- and click on the client you're interested in.
  220. --
  221. -- To match on the WM_NAME, you can use 'title' in the same way that
  222. -- 'className' and 'resource' are used below.
  223. --
  224. myManageHook = composeAll
  225. [ className =? "MPlayer" --> doFloat
  226. , className =? "Reference Net Workshop" --> doFloat
  227. , className =? "sun-awt-X11-XFramePeer" --> doFloat
  228. , className =? "de-renew-plugin-Loader" --> doFloat
  229. , className =? "Gimp" --> doFloat
  230. , className =? "Vidalia" --> doFloat
  231. , className =? "gui-worksheet" --> doFloat
  232. , className =? "Emacs" --> doFloat
  233. , className =? "Pidgin" --> doFloat
  234. , className =? "Inkscape" --> doFloat
  235. , className =? "MuPDF" --> doFloat
  236. , className =? "Gitk" --> doFloat
  237. , className =? "Viewnior" --> doFloat
  238. -- , className =? "remac.py" --> doFloat
  239. , resource =? "desktop_window" --> doIgnore
  240. , title =? "Firefox Preferences" --> doFloat
  241. , title =? "VisualizationPy" --> doFloat
  242. , resource =? "kdesktop" --> doIgnore ]
  243. ------------------------------------------------------------------------
  244. -- Event handling
  245. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  246. --
  247. -- Defines a custom handler function for X Events. The function should
  248. -- return (All True) if the default handler is to be run afterwards. To
  249. -- combine event hooks use mappend or mconcat from Data.Monoid.
  250. --
  251. myEventHook = mempty
  252. ------------------------------------------------------------------------
  253. -- Status bars and logging
  254. -- Perform an arbitrary action on each internal state change or X event.
  255. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  256. --
  257. myLogHook = return ()
  258. ------------------------------------------------------------------------
  259. -- Startup hook
  260. -- Perform an arbitrary action each time xmonad starts or is restarted
  261. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  262. -- per-workspace layout choices.
  263. --
  264. -- By default, do nothing.
  265. myStartupHook = return ()
  266. ------------------------------------------------------------------------
  267. -- Now run xmonad with all the defaults we set up.
  268. -- Run xmonad with the settings you specify. No need to modify this.
  269. --
  270. main = xmonad defaults
  271. -- A structure containing your configuration settings, overriding
  272. -- fields in the default config. Any you don't override, will
  273. -- use the defaults defined in xmonad/XMonad/Config.hs
  274. --
  275. -- No need to modify this.
  276. --
  277. defaults = defaultConfig {
  278. -- simple stuff
  279. terminal = myTerminal,
  280. focusFollowsMouse = myFocusFollowsMouse,
  281. clickJustFocuses = myClickJustFocuses,
  282. borderWidth = myBorderWidth,
  283. modMask = myModMask,
  284. workspaces = myWorkspaces,
  285. normalBorderColor = myNormalBorderColor,
  286. focusedBorderColor = myFocusedBorderColor,
  287. -- key bindings
  288. keys = myKeys,
  289. mouseBindings = myMouseBindings,
  290. -- hooks, layouts
  291. layoutHook = myLayout, -- showWName myLayout,
  292. manageHook = myManageHook,
  293. handleEventHook = myEventHook,
  294. logHook = myLogHook,
  295. startupHook = myStartupHook
  296. }