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.

xmonad.hs 8.4KB

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