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

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