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.

200 lines
8.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 = "konsole"
  52. -- i3lock is a locking mechanism presumably designed originally for i3.
  53. -- It has a nice little input indicator thingy, and with -i can show an
  54. -- image:
  55. myLockScreen = "i3lock -t --image tree_bg.png"
  56. -- rofi is a launcher similar to dmenu, with some neat extra features.
  57. -- It's in Debian - apt-get install rofi
  58. myLauncher = "rofi -show run -font 'mono 28'"
  59. manageScratchPad :: ManageHook
  60. manageScratchPad = scratchpadManageHookDefault
  61. myManageHook = composeAll
  62. [ resource =? "desktop_window" --> doIgnore
  63. , className =? "Gimp" --> doFloat
  64. , className =? "Vncviewer" --> doFloat
  65. , className =? "Nautilus" --> doFloat
  66. , className =? "Svkbd" --> doFloat
  67. , className =? "Google-chrome" --> doShift "web"
  68. , className =? "Firefox" --> doShift "web"
  69. , isFullscreen --> doFullFloat
  70. , namedScratchpadManageHook scratchpads
  71. ]
  72. -- Named scratchpads - a terminal and a tmux session for editing notes in. I
  73. -- use gnome-terminal with a role for both of these instead of uxterm with a
  74. -- title, because title gets changed by running stuff inside of xterms, seemingly
  75. -- no matter how things are configured. See also /bin/notesession.
  76. scratchpads =
  77. [ NS "scratch" "gnome-terminal --role scratch" (role =? "scratch")
  78. -- this goes: start-x, start-y, width (1.0 is full screen), height:
  79. (customFloating $ W.RationalRect 0.0 0.0 1.0 0.5)
  80. , NS "notes" "gnome-terminal --role=notesession -e notesession" (role =? "notesession")
  81. (customFloating $ W.RationalRect 0.3 0.0 0.7 0.95)
  82. ] where role = stringProperty "WM_WINDOW_ROLE"
  83. myTabConfig = def
  84. { inactiveBorderColor = colorBackground
  85. , activeBorderColor = colorGreen
  86. , activeColor = colorCurrent
  87. , inactiveColor = colorBackground
  88. , inactiveTextColor = colorComment
  89. , activeTextColor = colorForeground
  90. , fontName = "xft: Droid Sans 20"
  91. , decoHeight = 50
  92. }
  93. myLayout = avoidStruts
  94. $ toggleLayouts tiledSpace
  95. $ smartBorders
  96. $ basicRotate
  97. where
  98. basicRotate = tabbed shrinkText myTabConfig |||
  99. fullTiled |||
  100. Mirror fullTiled
  101. --- Full |||
  102. -- ||| Grid
  103. -- ||| ThreeColMid 1 (3/100) (1/2)
  104. tiledSpace = spacing 60 $ ResizableTall nmaster delta ratio []
  105. fullTiled = ResizableTall nmaster delta ratio []
  106. -- The default number of windows in the master pane
  107. nmaster = 1
  108. -- Default proportion of screen occupied by master pane
  109. ratio = toRational (2/(1 + sqrt 5 :: Double))
  110. -- Percent of screen to increment by when resizing panes
  111. delta = 5/100
  112. -- A breakdown of desired workspaces:
  113. -- [NSP] - named scratchpads; created implicitly by namedScratchpad stuff
  114. -- - one gnome-terminal
  115. -- - one gnome-terminal with a tmux containing a vim with notes
  116. -- ...plus:
  117. myWorkspaces =
  118. [ "top" -- monitoring, logs, and remote shells
  119. , "mail" -- originally for thunderbird, now a rarely-used spare
  120. , "irc" -- chat clients (weechat, hipchat, slack, signal, etc.)
  121. , "code" -- development and writing
  122. , "browse" -- web browser(s)
  123. , "org" -- a vim with notes file and such
  124. , "media" -- photos, graphics work, video, file managers, etc.
  125. ]
  126. -- ewmh is Extended Window Manager Hints, useful for wmctrl(1):
  127. -- https://en.wikipedia.org/wiki/Extended_Window_Manager_Hints
  128. main = do
  129. config_with_xmobar <- statusBar myBar myPP toggleStrutsKey defaults
  130. xmonad $ ewmh config_with_xmobar {
  131. manageHook = manageDocks <+> myManageHook,
  132. modMask = mod4Mask
  133. }
  134. -- xmobar setup:
  135. -- https://wiki.archlinux.org/index.php/Xmonad#More_configurable
  136. -- https://stackoverflow.com/questions/21218309/how-to-use-dzen-instead-of-xmobar-in-this-unusual-setup#21445159
  137. myBar = "xmobar"
  138. myPP = xmobarPP { ppCurrent = xmobarColor "green" "" . wrap "@" "" . shorten 50 }
  139. toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)
  140. defaults = def {
  141. terminal = myTerminal
  142. , borderWidth = 3
  143. , normalBorderColor = colorGreen
  144. , focusedBorderColor = colorBlue
  145. , layoutHook = smartBorders $ myLayout
  146. , manageHook = manageScratchPad <+> myManageHook
  147. , workspaces = myWorkspaces
  148. , handleEventHook = XMonad.Hooks.EwmhDesktops.fullscreenEventHook
  149. } `additionalKeysP`
  150. -- http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Util-EZConfig.html
  151. [ ("M-<Right>", nextWS)
  152. -- , ("M-s", scratchpadSpawnActionTerminal $ myTerminal)
  153. , ("M-p", spawn myLauncher)
  154. , ("M-S-l", spawn myLockScreen)
  155. , ("M-<Left>", prevWS)
  156. , ("M-S-<Down>", shiftToNext)
  157. , ("M-S-<Up>", shiftToPrev)
  158. , ("M-S-<Right>", shiftNextScreen)
  159. , ("M-S-<Left>", shiftPrevScreen)
  160. , ("M-z", toggleWS)
  161. , ("M-g", goToSelected def)
  162. , ("M-S-g", spawn "jump-to-window")
  163. -- Invert screen colors using https://github.com/zoltanp/xrandr-invert-colors
  164. -- can be helpful for legibility in really bright or dark environments:
  165. , ("M-i", spawn "xrandr-invert-colors")
  166. -- A basic scratchpad, by analogy to the ~ console in Quake:
  167. , ("M-`", namedScratchpadAction scratchpads "scratch")
  168. -- Notes - I am not sure why I can't use mod-n here, but works with mod-shift-n:
  169. , ("M-S-n", namedScratchpadAction scratchpads "notes")
  170. -- Special laptopish media keys
  171. , ("<XF86AudioMute>", spawn "amixer set Master toggle")
  172. , ("<XF86AudioLowerVolume>", spawn "amixer set Master 2%- unmute")
  173. , ("<XF86AudioRaiseVolume>", spawn "amixer set Master 2%+ unmute")
  174. , ("<XF86MonBrightnessDown>", spawn "xbacklight -dec 5")
  175. , ("<XF86MonBrightnessUp>", spawn "xbacklight -inc 5")
  176. ]