Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
9.0 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. -- This is my xmonad configuration. Take it as read that I do not know what I
  2. -- am doing in this file. It is pure magpie behavior with little underlying
  3. -- logic. I do not know Haskell.
  4. -- Some sources:
  5. -- Things I have bookmarked: https://pinboard.in/search/u:brennen?query=xmonad
  6. -- Tyler Cipriani's setup: https://github.com/thcipriani/dotfiles/blob/master/xmonad/xmonad.hs
  7. -- Ben LeMasurier's setup: https://github.com/benlemasurier/ben/blob/master/.xmonad/xmonad.hs
  8. -- http://haskell.org/haskellwiki/Xmonad/Config_archive/John_Goerzen%27s_Configuration
  9. -- http://www.xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Doc-Configuring.html
  10. -- http://hackage.haskell.org/packages/archive/xmonad-contrib/0.8.1/doc/html/XMonad-Doc-Extending.html
  11. -- http://hackage.haskell.org/packages/archive/xmonad-contrib/0.8.1/doc/html/XMonad-Actions-CycleWS.html
  12. -- http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-GridSelect.html
  13. import XMonad
  14. import XMonad.Actions.CycleWS
  15. import XMonad.Actions.GridSelect
  16. import XMonad.Hooks.DynamicLog
  17. import XMonad.Hooks.EwmhDesktops
  18. import XMonad.Hooks.ManageDocks
  19. import XMonad.Hooks.ManageHelpers(isFullscreen, isDialog, doFullFloat, doCenterFloat)
  20. import XMonad.Layout.Accordion
  21. import XMonad.Layout.Fullscreen
  22. import XMonad.Layout.Grid
  23. import XMonad.Layout.NoBorders
  24. import XMonad.Layout.ResizableTile
  25. import XMonad.Layout.Spacing
  26. import XMonad.Layout.Tabbed
  27. import XMonad.Layout.ThreeColumns
  28. import XMonad.Layout.ToggleLayouts
  29. import XMonad.Util.EZConfig(additionalKeysP) -- Easier keybindings
  30. import XMonad.Util.NamedScratchpad
  31. import XMonad.Util.NamedWindows
  32. import XMonad.Util.Run(hPutStrLn)
  33. import XMonad.Util.Run(runInTerm) -- Need this guy for keybindings to external commands
  34. import XMonad.Util.Run(spawnPipe) -- Need this guy for talking to xmobar
  35. import XMonad.Util.Run(unsafeSpawn) -- Need this guy for keybindings to external commands
  36. import XMonad.Util.Scratchpad
  37. import qualified XMonad.StackSet as W -- used by the scratchpad stuff below
  38. -- Tomorrow Night Colors:
  39. colorBackground = "#1d1f21"
  40. colorCurrent = "#282a2e"
  41. colorSelection = "#373b41"
  42. colorForeground = "#c5c8c6"
  43. colorComment = "#969896"
  44. colorRed = "#cc6666"
  45. colorOrange = "#de935f"
  46. colorYellow = "#f0c674"
  47. colorGreen = "#b5bd68"
  48. colorAqua = "#8abeb7"
  49. colorBlue = "#81a2be"
  50. colorPurple = "#b294bb"
  51. -- myTerminal = "uxterm"
  52. -- myTerminal = "gnome-terminal"
  53. -- myTerminal = "alacritty"
  54. myTerminal = "konsole"
  55. -- i3lock is a locking mechanism presumably designed originally for i3.
  56. -- It has a nice little input indicator thingy, and with -i can show an
  57. -- image:
  58. myLockScreen = "phoonlock"
  59. -- rofi is a launcher similar to dmenu, with some neat extra features.
  60. -- It's in Debian - apt-get install rofi
  61. myLauncher = "rofi -show run -font 'mono 14'"
  62. manageScratchPad :: ManageHook
  63. manageScratchPad = scratchpadManageHookDefault
  64. myManageHook = composeAll
  65. [ resource =? "desktop_window" --> doIgnore
  66. , className =? "Gimp" --> doFloat
  67. , className =? "Vncviewer" --> doFloat
  68. -- , className =? "Nautilus" --> doFloat
  69. , className =? "Svkbd" --> doFloat
  70. , className =? "Google-chrome" --> doShift "web"
  71. , className =? "Firefox" --> doShift "web"
  72. , isFullscreen --> doFullFloat
  73. , namedScratchpadManageHook scratchpads
  74. ]
  75. -- Named scratchpads - a terminal and a tmux session for editing notes in. I
  76. -- use gnome-terminal with a role for both of these instead of uxterm with a
  77. -- title, because title gets changed by running stuff inside of xterms,
  78. -- seemingly no matter how things are configured.
  79. --
  80. -- NamedScratchpad docs:
  81. -- https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Util-NamedScratchpad.html
  82. --
  83. -- If you want a regular window here instead of a floaty one, use
  84. -- `(nonFloating)` instead of (customFloating ...). It turns out that the
  85. -- floating ones are a lot easier to toggle over a workspace without otherwise
  86. -- messing with window management, since you don't have to muck around with
  87. -- layouts at all, size is predictable, etc. You probably want floating.
  88. --
  89. -- See also /bin/notesession.
  90. scratchpads =
  91. [ NS "scratch" "gnome-terminal --role scratch" (role =? "scratch")
  92. -- this goes: start-x, start-y, width (1.0 is full screen), height:
  93. (customFloating $ W.RationalRect 0.0 0.0 1.0 0.5)
  94. , NS "notes" "gnome-terminal --role=notesession -e notesession" (role =? "notesession")
  95. (customFloating $ W.RationalRect 0.2 0.03 0.6 0.90)
  96. ] where role = stringProperty "WM_WINDOW_ROLE"
  97. myTabConfig = def
  98. { inactiveBorderColor = colorBackground
  99. , activeBorderColor = colorGreen
  100. , activeColor = colorCurrent
  101. , inactiveColor = colorBackground
  102. , inactiveTextColor = colorComment
  103. , activeTextColor = colorForeground
  104. , fontName = "xft: Droid Sans 14"
  105. , decoHeight = 25
  106. }
  107. myLayout = avoidStruts
  108. $ toggleLayouts tiledSpace
  109. $ smartBorders
  110. $ basicRotate
  111. where
  112. basicRotate = tabbedBottom shrinkText myTabConfig |||
  113. fullTiled |||
  114. Mirror fullTiled
  115. --- Full |||
  116. -- ||| Grid
  117. -- ||| ThreeColMid 1 (3/100) (1/2)
  118. tiledSpace = spacing 60 $ ResizableTall nmaster delta ratio []
  119. fullTiled = ResizableTall nmaster delta ratio []
  120. -- The default number of windows in the master pane
  121. nmaster = 1
  122. -- Default proportion of screen occupied by master pane
  123. ratio = toRational (2/(1 + sqrt 5 :: Double))
  124. -- Percent of screen to increment by when resizing panes
  125. delta = 5/100
  126. -- A breakdown of desired workspaces:
  127. -- [NSP] - named scratchpads; created implicitly by namedScratchpad stuff
  128. -- - one gnome-terminal
  129. -- - one gnome-terminal with a tmux containing a vim with notes
  130. -- ...plus:
  131. myWorkspaces =
  132. [ "top" -- monitoring, logs, and remote shells
  133. , "mail" -- originally for thunderbird, now a rarely-used spare
  134. , "irc" -- chat clients (weechat, hipchat, slack, signal, etc.)
  135. , "code" -- development and writing
  136. , "browse" -- web browser(s)
  137. , "org" -- a vim with notes file and such
  138. , "media" -- photos, graphics work, video, file managers, etc.
  139. ]
  140. -- ewmh is Extended Window Manager Hints, useful for wmctrl(1):
  141. -- https://en.wikipedia.org/wiki/Extended_Window_Manager_Hints
  142. main = do
  143. config_with_xmobar <- statusBar myBar myPP toggleStrutsKey defaults
  144. xmonad $ ewmh config_with_xmobar {
  145. manageHook = manageDocks <+> myManageHook,
  146. modMask = mod4Mask
  147. }
  148. -- xmobar setup:
  149. -- https://wiki.archlinux.org/index.php/Xmonad#More_configurable
  150. -- https://stackoverflow.com/questions/21218309/how-to-use-dzen-instead-of-xmobar-in-this-unusual-setup#21445159
  151. myBar = "xmobar"
  152. myPP = xmobarPP { ppCurrent = xmobarColor "green" "" . wrap "@" "" . shorten 50 }
  153. -- mod-b to toggle xmobar visibility:
  154. toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)
  155. defaults = def {
  156. terminal = myTerminal
  157. , borderWidth = 3
  158. , normalBorderColor = colorGreen
  159. , focusedBorderColor = colorBlue
  160. , layoutHook = smartBorders $ myLayout
  161. , manageHook = manageScratchPad <+> myManageHook
  162. , workspaces = myWorkspaces
  163. , handleEventHook = XMonad.Hooks.EwmhDesktops.fullscreenEventHook
  164. } `additionalKeysP`
  165. -- http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Util-EZConfig.html
  166. [ ("M-p", spawn myLauncher)
  167. -- , ("M-s", scratchpadSpawnActionTerminal $ myTerminal)
  168. , ("M-S-l", spawn myLockScreen)
  169. , ("M-S-<Down>", shiftToNext)
  170. , ("M-S-<Up>", shiftToPrev)
  171. , ("M-S-<Right>", shiftNextScreen)
  172. , ("M-S-<Left>", shiftPrevScreen)
  173. , ("M-z", toggleWS)
  174. , ("M-g", goToSelected def)
  175. , ("M-S-g", spawn "jump-to-window")
  176. -- The following could use just nextWS / prevWS, but I got tired of
  177. -- workspaces swapping between displays when I cycled through with
  178. -- arrow keys; this version avoids that entirely.
  179. -- Move to the next/prev workspaces not already visible on a screen:
  180. , ("M-<Left>", moveTo Prev HiddenWS)
  181. , ("M-<Right>", moveTo Next HiddenWS)
  182. -- Invert screen colors using https://github.com/zoltanp/xrandr-invert-colors
  183. -- can be helpful for legibility in really bright or dark environments:
  184. , ("M-i", spawn "xrandr-invert-colors")
  185. -- Screenshots:
  186. , ("<Print>", spawn "grab")
  187. -- A basic scratchpad, by analogy to the ~ console in Quake:
  188. , ("M-`", namedScratchpadAction scratchpads "scratch")
  189. -- Notes:
  190. , ("M-S-n", namedScratchpadAction scratchpads "notes")
  191. , ("M-n", namedScratchpadAction scratchpads "notes")
  192. -- Special laptopish media keys:
  193. , ("<XF86AudioMute>", spawn "amixer set Master toggle")
  194. , ("<XF86AudioLowerVolume>", spawn "amixer set Master 2%- unmute")
  195. , ("<XF86AudioRaiseVolume>", spawn "amixer set Master 2%+ unmute")
  196. , ("<XF86MonBrightnessDown>", spawn "xbacklight -dec 5")
  197. , ("<XF86MonBrightnessUp>", spawn "xbacklight -inc 5")
  198. ]