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.

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