Browse Source

Switching from BSPWM to XMonad, needed to make some adjustments

master
Peter J. Jones 1 month ago
parent
commit
14e6ae4045
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
6 changed files with 203 additions and 301 deletions
  1. 77
    0
      scripts/run-in-xephyr.sh
  2. 61
    170
      src/XMonad/Local/Keys.hs
  3. 49
    41
      src/XMonad/Local/Layout.hs
  4. 3
    3
      src/XMonad/Local/Theme.hs
  5. 10
    82
      src/XMonad/Local/Workspaces.hs
  6. 3
    5
      xmonadrc.hs

+ 77
- 0
scripts/run-in-xephyr.sh View File

@@ -0,0 +1,77 @@
1
+#!/bin/sh -eu
2
+
3
+################################################################################
4
+usage () {
5
+  cat <<EOF
6
+Usage: run-in-xephyr.sh [options]
7
+
8
+  -d NxN  Set the screen size to NxN
9
+  -h      This message
10
+  -n NUM  Set the internal DISPLAY to NUM
11
+  -s NUM  Set the number of screens to NUM
12
+EOF
13
+}
14
+
15
+################################################################################
16
+SCREENS=1
17
+SCREEN_SIZE="800x600"
18
+DISPLAY_NUMBER=5
19
+
20
+################################################################################
21
+while getopts "d:hn:s:" o; do
22
+  case "${o}" in
23
+    d) SCREEN_SIZE=$OPTARG
24
+       ;;
25
+
26
+    h) usage
27
+       exit
28
+       ;;
29
+
30
+    n) DISPLAY_NUMBER=$OPTARG
31
+       ;;
32
+
33
+    s) SCREENS=$OPTARG
34
+       ;;
35
+
36
+    *) echo; usage
37
+       exit 1
38
+       ;;
39
+  esac
40
+done
41
+
42
+shift $((OPTIND-1))
43
+
44
+################################################################################
45
+XMONAD_CONFIG_DIR=$(pwd)/state/config
46
+XMONAD_CACHE_DIR=$(pwd)/state/cache
47
+XMONAD_DATA_DIR=$(pwd)/state/data
48
+export XMONAD_CONFIG_DIR XMONAD_CACHE_DIR XMONAD_DATA_DIR
49
+
50
+mkdir -p "$XMONAD_CONFIG_DIR" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR"
51
+echo "xmonad will store state files in $(pwd)/state"
52
+
53
+################################################################################
54
+SCREEN_COUNTER=0
55
+SCREEN_OPTS=""
56
+X_OFFSET_CURRENT="0"
57
+X_OFFSET_ADD=$(echo "$SCREEN_SIZE" | cut -dx -f1)
58
+
59
+while expr "$SCREEN_COUNTER" "<" "$SCREENS"; do
60
+  SCREEN_OPTS="$SCREEN_OPTS -origin ${X_OFFSET_CURRENT},0 -screen ${SCREEN_SIZE}+${X_OFFSET_CURRENT}"
61
+  SCREEN_COUNTER=$(("$SCREEN_COUNTER" + 1))
62
+  X_OFFSET_CURRENT=$(("$X_OFFSET_CURRENT" + "$X_OFFSET_ADD"))
63
+done
64
+
65
+(
66
+  # shellcheck disable=SC2086
67
+  Xephyr $SCREEN_OPTS +xinerama +extension RANDR \
68
+         -ac -br -reset -terminate -verbosity 10 \
69
+         -softCursor ":$DISPLAY_NUMBER" &
70
+
71
+  export DISPLAY=":$DISPLAY_NUMBER"
72
+  echo "Waiting for windows to appear..." && sleep 2
73
+
74
+  xterm -hold xrandr &
75
+  xterm &
76
+  dist/build/xmonadrc/xmonadrc
77
+)

+ 61
- 170
src/XMonad/Local/Keys.hs View File

@@ -13,9 +13,9 @@ module XMonad.Local.Keys (keys, rawKeys) where
13 13
 --------------------------------------------------------------------------------
14 14
 -- General Haskell Packages.
15 15
 import qualified Data.Map as M
16
-import Data.Version (showVersion)
17 16
 import Graphics.X11.Xlib
18 17
 import System.Directory
18
+import System.FilePath ((</>))
19 19
 
20 20
 --------------------------------------------------------------------------------
21 21
 -- Package: xmonad.
@@ -25,6 +25,7 @@ import qualified XMonad.StackSet as W
25 25
 --------------------------------------------------------------------------------
26 26
 -- Package: xmonad-contrib.
27 27
 import XMonad.Actions.CopyWindow (kill1)
28
+import XMonad.Actions.CycleSelectedLayouts (cycleThroughLayouts)
28 29
 import XMonad.Actions.DynamicProjects (switchProjectPrompt)
29 30
 import XMonad.Actions.GroupNavigation (Direction (..), nextMatch)
30 31
 import XMonad.Actions.Navigation2D
@@ -34,42 +35,23 @@ import XMonad.Actions.TagWindows (addTag, delTag, withTagged)
34 35
 import XMonad.Actions.UpdatePointer (updatePointer)
35 36
 import XMonad.Hooks.ManageDocks (ToggleStruts(..))
36 37
 import XMonad.Hooks.UrgencyHook (focusUrgent)
37
-import XMonad.Layout.BinarySpacePartition hiding (Swap)
38 38
 import XMonad.Layout.ComboP (PartitionWins(..))
39 39
 import XMonad.Layout.Gaps (GapMessage(..))
40
-import XMonad.Layout.LayoutCombinators (JumpToLayout(..))
41 40
 import XMonad.Layout.ResizableTile
41
+import XMonad.Layout.Spacing (incWindowSpacing, decWindowSpacing, toggleWindowSpacingEnabled)
42 42
 import XMonad.Layout.ToggleLayouts (ToggleLayout(..))
43
-import XMonad.Prompt.ConfirmPrompt (confirmPrompt)
44 43
 import XMonad.Prompt.Shell (shellPrompt)
45 44
 import XMonad.Prompt.Window (WindowPrompt(..), windowPrompt, windowMultiPrompt, allWindows, wsWindows)
46 45
 import XMonad.Prompt.XMonad (xmonadPrompt)
47 46
 import XMonad.Util.EZConfig (mkKeymap)
48
-import XMonad.Util.NamedScratchpad (namedScratchpadAction)
49 47
 
50 48
 --------------------------------------------------------------------------------
51 49
 -- Local modules.
52
-import Paths_xmonadrc (version)
53 50
 import XMonad.Local.Layout (selectLayoutByName)
54 51
 import XMonad.Local.Music (radioPrompt)
55
-import XMonad.Local.Prompt (promptConfig)
56 52
 import qualified XMonad.Local.Prompt as Local
57 53
 import XMonad.Local.Tagging
58
-import XMonad.Local.Workspaces (asKey, viewPrevWS, scratchPads)
59
-
60
---------------------------------------------------------------------------------
61
-data GPResize = GPExpandL
62
-              | GPExpandR
63
-              | GPExpandU
64
-              | GPExpandD
65
-              | GPShrinkL
66
-              | GPShrinkR
67
-              | GPShrinkU
68
-              | GPShrinkD
69
-
70
-data LayoutType = BSP    -- ^ Binary Space Partition
71
-                | Other  -- ^ Other (generic) layout
54
+import XMonad.Local.Workspaces (asKey, viewPrevWS)
72 55
 
73 56
 --------------------------------------------------------------------------------
74 57
 -- Join all the key maps into a single list and send it through @mkKeymap@.
@@ -105,10 +87,10 @@ withUpdatePointer = map addAction
105 87
 -- Specifically manage my prefix key (C-z), and for controlling XMonad.
106 88
 baseKeys :: XConfig Layout -> [(String, X ())]
107 89
 baseKeys _ =
108
-  [ ("M-g",           return ()) -- Same as above.
109
-  , ("M-x M-r",       restart "xmonadrc" True)
110
-  , ("M-x M-d",       restartIntoDebugging)
111
-  , ("M-x M-<Space>", xmonadPrompt Local.promptConfig)
90
+  [ ("M-g",         return ()) -- Same as above.
91
+  , ("M-x r",       restartIntoDebugging)
92
+  , ("M-x <Space>", xmonadPrompt Local.promptConfig)
93
+  , ("M-x <Esc>",   spawn "systemctl --user restart compton.service")
112 94
   ]
113 95
 
114 96
 --------------------------------------------------------------------------------
@@ -116,53 +98,52 @@ baseKeys _ =
116 98
 windowKeys :: XConfig Layout -> [(String, X ())]
117 99
 windowKeys _ =
118 100
   -- Focusing Windows:
119
-  [ ("M-w M-l",   nextMatch History (return True))
120
-  , ("M-w M-b",   windows W.focusUp)
121
-  , ("M-w M-f",   windows W.focusDown)
122
-  , ("M-w M-u",   focusUrgent)
123
-  , ("M-w M-o",   windowPromptGoto)
124
-  , ("M-w M-c",   windowPrompt Local.promptConfig BringCopy allWindows)
125
-  , ("M-o",       windowPromptGoto')
126
-  , ("M-n",       windowGo D True)
127
-  , ("M-p",       windowGo U True)
128
-  , ("M-f",       windowGo R True)
129
-  , ("M-b",       windowGo L True)
130
-  , ("M-w M-m",   windows W.focusMaster)
101
+  [ ("M-;",     nextMatch History (return True))
102
+  , ("M-w k",   windows W.focusUp)
103
+  , ("M-w j",   windows W.focusDown)
104
+  , ("M-u",     focusUrgent)
105
+  , ("M-o",     windowPromptGoto')
106
+  , ("M-C-o",   windowPromptGoto)
107
+  , ("M-w c",   windowPrompt Local.promptConfig BringCopy allWindows)
108
+  , ("M-j",     windowGo D True)
109
+  , ("M-k",     windowGo U True)
110
+  , ("M-l",     windowGo R True)
111
+  , ("M-h",     windowGo L True)
112
+  , ("M-w m",   windows W.focusMaster)
131 113
 
132 114
   -- Moving Windows:
133
-  , ("M-m M-f",  windowSwap R False)
134
-  , ("M-m M-b",  windowSwap L False)
135
-  , ("M-m M-n",  windowSwap D False)
136
-  , ("M-m M-p",  windowSwap U False)
137
-  , ("M-m M-m",  promote) -- Promote current window to master.
115
+  , ("M-M1-l",  windowSwap R False)
116
+  , ("M-M1-h",  windowSwap L False)
117
+  , ("M-M1-j",  windowSwap D False)
118
+  , ("M-M1-k",  windowSwap U False)
119
+  , ("M-m",     promote) -- Promote current window to master.
138 120
 
139 121
   -- Resizing Windows:
140
-  , ("M-<Left>",  sendResize GPExpandL)
141
-  , ("M-<Right>", sendResize GPShrinkL)
142
-  , ("M-<Up>",    sendResize GPExpandU)
143
-  , ("M-<Down>",  sendResize GPShrinkU)
144
-  , ("M-w -",     sendMessage $ IncMasterN (-1))
145
-  , ("M-w =",     sendMessage $ IncMasterN 1)
122
+  , ("M-C-h",   sendMessage Shrink)
123
+  , ("M-C-l",   sendMessage Expand)
124
+  , ("M-C-j",   sendMessage MirrorShrink)
125
+  , ("M-C-k",   sendMessage MirrorExpand)
126
+  , ("M-w -",   sendMessage $ IncMasterN (-1))
127
+  , ("M-w S-=", sendMessage $ IncMasterN 1)
146 128
 
147 129
   -- Window Layers and Killing and Yanking:
148
-  , ("M-w M-t",   withFocused $ windows . W.sink) -- Tile window.
149
-  , ("M-w M-k",   kill1) -- Kill the current window.
150
-  , ("M-k",       killWindowToBury)
151
-  , ("M-y",       yankWindowFromBury)
130
+  , ("M-w t",   withFocused $ windows . W.sink) -- Tile window.
131
+  , ("M-q",     kill1) -- Kill the current window.
132
+  , ("M-b",     killWindowToBury)
133
+  , ("M-v",     yankWindowFromBury)
152 134
   ]
153 135
 
154 136
 --------------------------------------------------------------------------------
155 137
 -- Navigate windows by using tags.
156 138
 windowTagKeys :: XConfig Layout -> [(String, X ())]
157 139
 windowTagKeys _ =
158
-  [ ("M-t M-<Space>", tagPrompt Local.promptConfig)
159
-  , ("M-S-t",         tagPrompt Local.promptConfig)
160
-  , ("M-h",           secondaryJumpTagUp)
161
-  , ("M-j",           primaryJumpTagUp)
162
-  , ("M-t M-a",       addFocusTag)
163
-  , ("M-t M-d",       rmFocusTag)
164
-  , ("M-t M-j",       tagPrompt' Local.promptConfig [SetJumpTag])
165
-  , ("M-t M-r",       rmFocusTagAll >> addFocusTag)
140
+  [ ("M-/",   tagPrompt Local.promptConfig)
141
+  , ("M-a",   primaryJumpTagUp)
142
+  , ("M-s",   secondaryJumpTagUp)
143
+  , ("M-t a", addFocusTag)
144
+  , ("M-t d", rmFocusTag)
145
+  , ("M-t j", tagPrompt' Local.promptConfig [SetJumpTag])
146
+  , ("M-t r", rmFocusTagAll >> addFocusTag)
166 147
   ] ++ numberedTags
167 148
   where
168 149
     addFocusTag :: X ()
@@ -193,8 +174,7 @@ windowTagKeys _ =
193 174
 -- Keys for manipulating workspaces.
194 175
 workspaceKeys :: XConfig Layout -> [(String, X ())]
195 176
 workspaceKeys _ =
196
-  [ ("M-w M-w",   viewPrevWS)
197
-  , ("M-S-w",     viewPrevWS)
177
+  [ ("M-'",       viewPrevWS)
198 178
   , ("M-<Space>", switchProjectPrompt  Local.promptConfig)
199 179
   ]
200 180
 
@@ -202,117 +182,42 @@ workspaceKeys _ =
202 182
 -- Layout switching and manipulation.
203 183
 layoutKeys :: XConfig Layout -> [(String, X ())]
204 184
 layoutKeys c =
205
-  [ ("M-l M-<Space>", selectLayoutByName Local.promptConfig)
206
-  , ("M-l <Esc>",     setLayout (layoutHook c)) -- Reset to default layout.
207
-  , ("M-l M-2",       sendMessage (JumpToLayout "2C"))
208
-  , ("M-l M-3",       sendMessage (JumpToLayout "3C"))
209
-  , ("M-l M-b",       sendMessage (JumpToLayout "BSP"))
210
-  , ("M-l M-f",       sendMessage (JumpToLayout "Focus") >> sendMessage PartitionWins)
211
-  , ("M-l M-l",       sendMessage (Toggle "Full"))
212
-  , ("M-l M-t",       sendMessage (JumpToLayout "Tall"))
213
-  , ("M-w M-g",       sendMessage ToggleGaps)
214
-  , ("M-w M-r",       sendMessage Rotate)
185
+  [ ("M-[",           selectLayoutByName Local.promptConfig)
186
+  , ("M-]",           sendMessage NextLayout)
187
+  , ("M-w <Esc>",     setLayout (layoutHook c)) -- Reset to default layout.
188
+  , ("M-<Backspace>", sendMessage (Toggle "Full"))
189
+  , ("M-S-8",         cycleThroughLayouts ["Auto", "Focus"])
190
+  , ("M-w g",         sendMessage ToggleGaps)
191
+  , ("M-w s",         toggleWindowSpacingEnabled)
215 192
   , ("M-w M-s",       sendMessage ToggleStruts)
193
+  , ("M-C-S-=",       incWindowSpacing 5)
194
+  , ("M-C--",         decWindowSpacing 5)
216 195
   ]
217 196
 
218 197
 --------------------------------------------------------------------------------
219 198
 -- Keys to manipulate screens (actual physical monitors).
220 199
 screenKeys :: XConfig Layout -> [(String, X ())]
221 200
 screenKeys _ =
222
-  [ ("M-s M-f",    onNextNeighbour def W.view)
223
-  , ("M-s M-b",    onPrevNeighbour def W.view)
224
-  , ("M-s M-s",    screenSwap L True)
225
-  , ("M1-<F11>",   spawn "xbacklight -dec 10")
226
-  , ("M1-<F12>",   spawn "xbacklight -inc 10")
227
-  , ("M1-S-<F11>", spawn "xbacklight -set 10")
228
-  , ("M1-S-<F12>", spawn "xbacklight -set 80")
201
+  [ ("M-)",  onNextNeighbour def W.view)
202
+  , ("M-(",  onPrevNeighbour def W.view)
203
+  , ("M-\\", screenSwap L True)
229 204
   ]
230 205
 
231 206
 --------------------------------------------------------------------------------
232 207
 -- Keys for launching applications.
233 208
 appKeys :: XConfig Layout -> [(String, X ())]
234
-appKeys _ =
235
-  [ ("M-<Return>",     spawn "urxvtc -e tmux-new-terminal")
236
-  , ("M-M1-<Return>",  spawn "urxvtc -name BigTerm -e tmux-new-terminal")
237
-  , ("M-M1-l",         spawn "lockscreen.sh")
238
-  , ("M-<Print> M-r",  spawn "screenshot.sh root")
239
-  , ("M-<Print> M-w",  spawn "screenshot.sh window")
240
-  , ("M-e M-e",        spawn "e -c") -- Start per-workspace Emacs.
241
-  , ("M-e M-r",        shellPrompt Local.promptConfig)
242
-
243
-    -- Laptops and keyboards with media/meta keys.
244
-  , ("<XF86WebCam>",         spawn "tptoggle.sh") -- Weird.
245
-  , ("<XF86TouchpadToggle>", spawn "tptoggle.sh")
246
-  , ("M1-<F6>",              spawn "tptoggle.sh")
247
-  , ("M1-<F10>",             spawn "xrandr-projector")
248
-
249
-    -- Scratch pads.
250
-  , ("M-; M-c", namedScratchpadAction scratchPads "calc")
251
-  , ("M-; M-p", namedScratchpadAction scratchPads "pass")
252
-  , ("M-; M-t", namedScratchpadAction scratchPads "todoist")
253
-  -- FIXME: , ("M-; M-;", closeAllNamedScratchpads scratchPads)
209
+appKeys c =
210
+  [ ("M-<Return>", spawn (terminal c))
211
+  , ("M-e",        spawn "e -c") -- Start per-workspace Emacs.
212
+  , ("M-<Esc>",    shellPrompt Local.promptConfig)
254 213
   ]
255 214
 
256 215
 --------------------------------------------------------------------------------
257 216
 -- Keys for controlling music and volume.
258 217
 musicKeys :: XConfig Layout -> [(String, X ())]
259 218
 musicKeys _ =
260
-    [ ("M-S-1",  playPause)
261
-    , ("M-S-2",  prevTrack)
262
-    , ("M-S-3",  nextTrack)
263
-    , ("M-S-4",  radioPrompt Local.promptConfig)
264
-    , ("M-S-5",  clearPlaylist)
265
-    , ("M-S-6",  audioMute)
266
-    , ("M-S-7",  audioLower)
267
-    , ("M-S-8",  audioRaise)
268
-
269
-      -- Keys for my laptop and keyboards with media keys.
270
-    , ("M-<XF86AudioMute>",        playPause)
271
-    , ("M-<XF86AudioLowerVolume>", prevTrack)
272
-    , ("M-<XF86AudioRaiseVolume>", nextTrack)
273
-    , ("<XF86AudioPlay>",          playPause)
274
-    , ("<XF86AudioPrev>",          prevTrack)
275
-    , ("<XF86AudioNext>",          nextTrack)
276
-    , ("<XF86AudioMute>",          audioMute)
277
-    , ("<XF86AudioLowerVolume>",   audioLower)
278
-    , ("<XF86AudioRaiseVolume>",   audioRaise)
219
+    [ ("M-r", radioPrompt Local.promptConfig)
279 220
     ]
280
-  where
281
-    playPause     = spawn "mpc-pause"
282
-    nextTrack     = spawn "mpc next"
283
-    prevTrack     = spawn "mpc prev"
284
-    clearPlaylist = spawn "mpc clear"
285
-    audioMute     = spawn "amixer set Master toggle"
286
-    audioLower    = spawn "amixer set Master 5%-"
287
-    audioRaise    = spawn "amixer set Master 5%+"
288
-
289
---------------------------------------------------------------------------------
290
-sendResize :: GPResize -> X ()
291
-sendResize movement = do
292
-  winset <- gets windowset
293
-  let lname = description . W.layout . W.workspace . W.current $ winset
294
-      ltype = case lname of
295
-              "BSP"         -> BSP
296
-              "Focus"       -> BSP
297
-              _             -> Other
298
-
299
-  case (ltype, movement) of
300
-    (BSP,   GPExpandL) -> sendMessage (ExpandTowards L)
301
-    (BSP,   GPExpandR) -> sendMessage (ExpandTowards R)
302
-    (BSP,   GPExpandU) -> sendMessage (ExpandTowards U)
303
-    (BSP,   GPExpandD) -> sendMessage (ExpandTowards D)
304
-    (BSP,   GPShrinkL) -> sendMessage (ShrinkFrom L)
305
-    (BSP,   GPShrinkR) -> sendMessage (ShrinkFrom R)
306
-    (BSP,   GPShrinkU) -> sendMessage (ShrinkFrom U)
307
-    (BSP,   GPShrinkD) -> sendMessage (ShrinkFrom D)
308
-    (Other, GPExpandL) -> sendMessage Shrink
309
-    (Other, GPExpandR) -> sendMessage Expand
310
-    (Other, GPExpandU) -> sendMessage MirrorShrink
311
-    (Other, GPExpandD) -> sendMessage MirrorExpand
312
-    (Other, GPShrinkL) -> sendMessage Expand
313
-    (Other, GPShrinkR) -> sendMessage Shrink
314
-    (Other, GPShrinkU) -> sendMessage MirrorExpand
315
-    (Other, GPShrinkD) -> sendMessage MirrorShrink
316 221
 
317 222
 --------------------------------------------------------------------------------
318 223
 -- | Restart XMonad but instead of starting the XMonad in @PATH@,
@@ -320,22 +225,7 @@ sendResize movement = do
320 225
 restartIntoDebugging :: X ()
321 226
 restartIntoDebugging = do
322 227
   home <- io getHomeDirectory
323
-
324
-  -- Path to my xmonad (as generated by `cabal new-build'):
325
-  let path = foldl (\x y -> x ++ "/" ++ y) home
326
-               [ "develop/rc/xmonadrc/dist-newstyle/build"
327
-               , "xmonadrc-" ++ showVersion version
328
-               , "build/xmonadrc/xmonadrc"
329
-               ]
330
-
331
-  exists <- io (doesFileExist path)
332
-
333
-  if exists
334
-    then restart path True
335
-    else do io (putStrLn ("bad path: " ++ path))
336
-            confirmPrompt promptConfig
337
-              "xmonad.errors for bad path"
338
-              (return ())
228
+  restart (home </> "src/rc/xmonadrc/dist/build/xmonadrc/xmonadrc")  True
339 229
 
340 230
 --------------------------------------------------------------------------------
341 231
 windowPromptGoto :: X ()

+ 49
- 41
src/XMonad/Local/Layout.hs View File

@@ -15,16 +15,18 @@ module XMonad.Local.Layout (layoutHook, selectLayoutByName) where
15 15
 --------------------------------------------------------------------------------
16 16
 import XMonad hiding ((|||), layoutHook, float)
17 17
 import XMonad.Layout.Accordion (Accordion(..))
18
-import XMonad.Layout.BinarySpacePartition (emptyBSP)
19
-import XMonad.Layout.ComboP (Property(..), combineTwoP)
20
-import XMonad.Layout.Gaps (Gaps, gaps)
18
+import XMonad.Layout.ComboP (PartitionWins(..), Property(..), combineTwoP)
19
+import XMonad.Layout.Gaps (gaps)
20
+import XMonad.Layout.GridVariants (SplitGrid(..))
21
+import qualified XMonad.Layout.GridVariants as Grid
22
+import XMonad.Layout.IfMax (ifMax)
21 23
 import XMonad.Layout.LayoutCombinators
22
-import XMonad.Layout.LayoutModifier
23 24
 import XMonad.Layout.Master (mastered)
24 25
 import XMonad.Layout.NoBorders (noBorders)
25
-import XMonad.Layout.Reflect (reflectHoriz, reflectVert)
26
+import XMonad.Layout.Reflect (reflectVert)
26 27
 import XMonad.Layout.Renamed (Rename(..), renamed)
27 28
 import XMonad.Layout.ResizableTile (ResizableTall(..))
29
+import XMonad.Layout.Spacing (Border(..), spacingRaw)
28 30
 import XMonad.Layout.ThreeColumns (ThreeCol(..))
29 31
 import XMonad.Layout.ToggleLayouts (toggleLayouts)
30 32
 import XMonad.Layout.TwoPane (TwoPane(..))
@@ -40,41 +42,43 @@ layoutHook =
40 42
       (noBorders fullscreen)
41 43
       allLays
42 44
   where
43
-    -- addSpace = renamed [CutWordsLeft 2] . spacingRaw 4
44
-
45
-    fullscreen :: ModifiedLayout Rename (ModifiedLayout Gaps Full) Window
46
-    fullscreen = renamed [Replace "Full"] (gaps (uniformGaps 60) Full)
47 45
     uniformGaps n = [(U, n), (D, n), (L, n), (R, n)] :: [(Direction2D,Int)]
46
+    uniformBorder n = Border n n n n
47
+    spacing = spacingRaw False (uniformBorder 10) True (uniformBorder 10) True
48
+
49
+    fullscreen = gaps (uniformGaps 60) Full
50
+    threeCols  = spacing $ ThreeColMid 1 (1/20) (1/2)
51
+    twoCols    = spacing $ mastered (1/100) (1/2) Accordion
52
+    twoPane    = spacing $ TwoPane (3/100) (1/2)
53
+    tall       = spacing $ ResizableTall 1 (1.5/100) (3/5) []
54
+    focusTag   = spacing $ only (Tagged "focus")
55
+    grid       = spacing $ SplitGrid Grid.L 2 2 (2/3) (1/2) 1
56
+
57
+    -- One window, centered on the screen.
58
+    centFull  = spacingRaw False (Border 20 20 200 200)
59
+                           True  (Border 0 0 0 0) False Full
48 60
 
49
-    threeCols = renamed [Replace "3C"]   (ThreeColMid 1 (1/20) (1/2))
50
-    twoCols   = renamed [Replace "2C"]   (mastered (1/100) (1/2) Accordion)
51
-    twoPane   = renamed [Replace "2P"]   (TwoPane (3/100) (1/2))
52
-    bspace    = renamed [Replace "BSP"]  emptyBSP
53
-    tall      = renamed [Replace "Tall"] (ResizableTall 1 (1.5/100) (3/5) [])
61
+    -- Automatically adapt to the number of open windows:
62
+    autoL = ifMax 1 centFull $
63
+            ifMax 2 twoPane threeCols
54 64
 
55 65
     -- A layout where windows you want to focus on are specified using
56 66
     -- @WindowProperties@.  Windows matching the given properties will
57 67
     -- be placed into the main layout.  Other windows are pushed to
58 68
     -- the top of the screen in a small @Accordion@.
59 69
     only = combineTwoP (reflectVert $ Mirror $ TwoPane 0 (9/10))
60
-                       bspace (Mirror Accordion)
61
-
62
-    focusTag = renamed [Replace "Focus"] $ only (Tagged "focus")
63
-
64
-    -- When I'm teaching a class I start with a weird layout before
65
-    -- focusing on specific windows using another layout.
66
-    projector = renamed [Replace "Projector"] topHalf where
67
-      topHalf    = combineTwoP (Mirror twoPane) bspace bottomHalf (ClassName "Emacs")
68
-      bottomHalf = combineTwoP (reflectHoriz twoPane) Full Full (ClassName ".zathura-wrapped_")
70
+                       twoCols (Mirror Accordion)
69 71
 
70 72
     -- All layouts put together.
71
-    allLays = bspace     |||
72
-              focusTag   |||
73
-              projector  |||
74
-              tall       |||
75
-              threeCols  |||
76
-              twoCols    |||
77
-              twoPane
73
+    allLays =
74
+      renamed [Replace "Auto"]  autoL     |||
75
+      renamed [Replace "Tall"]  tall      |||
76
+      renamed [Replace "3C"]    threeCols |||
77
+      renamed [Replace "2C"]    twoCols   |||
78
+      renamed [Replace "2P"]    twoPane   |||
79
+      renamed [Replace "Focus"] focusTag  |||
80
+      renamed [Replace "Grid"]  grid      |||
81
+      renamed [Replace "Full"]  fullscreen
78 82
 
79 83
 --------------------------------------------------------------------------------
80 84
 -- | A data type for the @XPrompt@ class.
@@ -91,16 +95,20 @@ selectLayoutByName conf =
91 95
 
92 96
   where
93 97
     go :: String -> X ()
94
-    go selected = case lookup selected layoutNames of
95
-                    Just name -> sendMessage (JumpToLayout name)
96
-                    Nothing   -> return ()
98
+    go selected =
99
+      case lookup selected layoutNames of
100
+        Nothing   -> return ()
101
+        Just name -> do sendMessage (JumpToLayout name)
102
+                        sendMessage PartitionWins
97 103
 
98 104
     layoutNames :: [(String, String)]
99
-    layoutNames = [ ("Tall",                         "Tall")
100
-                  , ("Binary Space Partition (BSP)", "BSP")
101
-                  , ("Two Columns (2C)",             "2C")
102
-                  , ("Two Pane (2P)",                "2P")
103
-                  , ("Three Columns (3C)",           "3C")
104
-                  , ("Projector",                    "Projector")
105
-                  , ("Focus",                        "Focus")
106
-                  ]
105
+    layoutNames =
106
+      [ ("Auto",               "Auto")
107
+      , ("Tall",               "Tall")
108
+      , ("Three Columns (3C)", "3C")
109
+      , ("Two Columns (2C)",   "2C")
110
+      , ("Two Pane (2P)",      "2P")
111
+      , ("Full",               "Full")
112
+      , ("Focus",              "Focus")
113
+      , ("Grid",               "Grid")
114
+      ]

+ 3
- 3
src/XMonad/Local/Theme.hs View File

@@ -23,9 +23,9 @@ import XMonad.Layout.Decoration
23 23
 
24 24
 --------------------------------------------------------------------------------
25 25
 xmonadColors :: XConfig a -> XConfig a
26
-xmonadColors x = x { normalBorderColor  = darkgray
27
-                   , focusedBorderColor = blue
28
-                   , borderWidth        = 1
26
+xmonadColors x = x { normalBorderColor  = "#444444"
27
+                   , focusedBorderColor = "#ff52bb"
28
+                   , borderWidth        = 5
29 29
                    }
30 30
 
31 31
 --------------------------------------------------------------------------------

+ 10
- 82
src/XMonad/Local/Workspaces.hs View File

@@ -11,7 +11,6 @@ the LICENSE file. -}
11 11
 module XMonad.Local.Workspaces
12 12
        ( projects
13 13
        , names
14
-       , scratchPads
15 14
        , asKey
16 15
        , viewPrevWS
17 16
        ) where
@@ -20,9 +19,7 @@ module XMonad.Local.Workspaces
20 19
 import Control.Monad (unless)
21 20
 import XMonad
22 21
 import XMonad.Actions.DynamicProjects
23
-import XMonad.Layout.LayoutCombinators (JumpToLayout(..))
24 22
 import qualified XMonad.StackSet as StackSet
25
-import XMonad.Util.NamedScratchpad
26 23
 
27 24
 --------------------------------------------------------------------------------
28 25
 projects :: [Project]
@@ -31,110 +28,41 @@ projects =
31 28
             , projectDirectory = "~/"
32 29
             , projectStartHook = Just $ do
33 30
                 spawn "e -c"
34
-                spawn "urxvtc"
35
-            }
36
-
37
-  , Project { projectName      = "clocks"
38
-            , projectDirectory = "~/"
39
-            , projectStartHook = Just $ do
40
-                sendMessage (JumpToLayout "BSP")
41
-                spawn "urxvtc -e ncmpcpp"
42
-                spawn "urxvtc -name BigTerm -e env TZ=America/New_York tty-clock -C 0 -c -f 'South Carolina'"
43
-                spawn "urxvtc -name BigTerm -e tty-clock -c -C 4 -f '%b. %d, %Y'"
31
+                spawn "konsole"
32
+                spawn "konsole"
44 33
             }
45 34
 
46 35
   , Project { projectName      = "browsers"
47 36
             , projectDirectory = "~/download"
48
-            , projectStartHook = Just $ do
49
-                sendMessage (JumpToLayout "BSP")
50
-                spawn "chromium"
51
-                spawn "chromium"
37
+            , projectStartHook = Just $ spawn "firefox"
52 38
             }
53 39
 
54 40
   , Project { projectName      = "mail"
55 41
             , projectDirectory = "~/"
56
-            , projectStartHook = Just $ do
57
-                sendMessage (JumpToLayout "3C")
58
-                spawn "e -cs irc -- -F '((name . \"irc\"))'"
59
-                spawn "e -cs gnus"
60
-            }
61
-
62
-  , Project { projectName      = "emacs"
63
-            , projectDirectory = "~/core/emacs"
64
-            , projectStartHook = Nothing
65
-            }
66
-
67
-  , Project { projectName      = "rip"
68
-            , projectDirectory = "~/documents/ripping"
69
-            , projectStartHook = Nothing
42
+            , projectStartHook = Just $ spawn "e -cs mail"
70 43
             }
71 44
 
72
-  , Project { projectName      = "xmonad"
73
-            , projectDirectory = "~/core/xmonadrc"
45
+  , Project { projectName      = "rc"
46
+            , projectDirectory = "~/src/rc"
74 47
             , projectStartHook = Nothing
75 48
             }
76 49
 
77 50
   , Project { projectName      = "rfa"
78
-            , projectDirectory = "~/develop/rfa"
51
+            , projectDirectory = "~/src/rfa"
79 52
             , projectStartHook = Nothing
80 53
             }
81 54
 
82
-    -- Classes I teach:
83
-  , Project { projectName      = "training"
84
-            , projectDirectory = "~/training/courses"
55
+  , Project { projectName      = "mint"
56
+            , projectDirectory = "~/src/mint"
85 57
             , projectStartHook = Nothing
86 58
             }
87 59
 
88
-  , Project { projectName      = "advjs"
89
-            , projectDirectory = "~/training/courses/src/javascript/advjs"
90
-            , projectStartHook = Just workshopHook
91
-            }
92
-
93
-  , Project { projectName      = "corejs"
94
-            , projectDirectory = "~/training/courses/src/javascript/corejs"
95
-            , projectStartHook = Just workshopHook
96
-            }
97
-
98
-  , Project { projectName      = "intcss"
99
-            , projectDirectory = "~/training/courses/src/css/intcss"
100
-            , projectStartHook = Just workshopHook
101
-            }
102 60
   ]
103
-  where
104
-    workshopHook = do
105
-      sendMessage (JumpToLayout "Projector")
106
-      spawn "e -c"
107
-      spawn "urxvtc -name BigTerm -e clockdown"
108
-      spawn "zathura"
109
-
110
-
111 61
 
112 62
 --------------------------------------------------------------------------------
113 63
 -- | Names of my workspaces.
114 64
 names :: [WorkspaceId]
115
-names = ["scratch", "tasks", "clocks", "browsers", "mail"]
116
-
117
---------------------------------------------------------------------------------
118
-scratchPads :: NamedScratchpads
119
-scratchPads =
120
-  [ NS { name  = "calc"
121
-       , cmd   = "e -c -s calc -e '(full-calc)' -- -F '((name . \"calculator\"))'"
122
-       , query = appName =? "calculator"
123
-       , hook  = floatOnRight
124
-       }
125
-  , NS { name = "pass"
126
-       , cmd  = "e -c -s pass -e '(passmm-list-passwords)' -- -F '((name . \"passwords\"))'"
127
-       , query = appName =? "passwords"
128
-       , hook  = floatOnRight
129
-       }
130
-  , NS { name  = "todoist"
131
-       , cmd   = "chromium --app=https://todoist.com/app"
132
-       , query = appName =? "todoist.com__app"
133
-       , hook  = floatOnRight
134
-       }
135
-  ]
136
-  where
137
-    floatOnRight = customFloating $ StackSet.RationalRect (2/3) 0 (1/3) 0.98
65
+names = ["scratch", "browsers", "agenda", "music", "mail", "chat"]
138 66
 
139 67
 --------------------------------------------------------------------------------
140 68
 -- | Helper function to translate workspace names into key names for

+ 3
- 5
xmonadrc.hs View File

@@ -18,7 +18,6 @@ import XMonad.Actions.Navigation2D
18 18
 import XMonad.Config.Desktop (desktopConfig)
19 19
 import XMonad.Hooks.ManageDocks (avoidStruts)
20 20
 import XMonad.Hooks.UrgencyHook hiding (urgencyConfig)
21
-import XMonad.Util.NamedScratchpad (namedScratchpadManageHook)
22 21
 
23 22
 --------------------------------------------------------------------------------
24 23
 import qualified XMonad.Local.Action as Local
@@ -33,12 +32,11 @@ import qualified XMonad.Local.Workspaces as Workspaces
33 32
 --
34 33
 -- config :: XConfig a
35 34
 config = desktopConfig
36
-  { terminal           = "urxvtc"
35
+  { terminal           = "konsole"
37 36
   , layoutHook         = avoidStruts Local.layoutHook
38 37
 
39 38
   , manageHook         = manageHook desktopConfig <>
40
-                         Local.manageHook <>
41
-                         namedScratchpadManageHook Workspaces.scratchPads
39
+                         Local.manageHook
42 40
 
43 41
   , handleEventHook    = handleEventHook desktopConfig <>
44 42
                          Local.handleEventHook
@@ -56,7 +54,7 @@ config = desktopConfig
56 54
 -- | Configuration for 'XMonad.Actions.Navigation2D'.
57 55
 navConf :: Navigation2DConfig
58 56
 navConf = def
59
-  { defaultTiledNavigation = centerNavigation
57
+  { defaultTiledNavigation = hybridOf sideNavigation centerNavigation
60 58
   }
61 59
 
62 60
 --------------------------------------------------------------------------------

Loading…
Cancel
Save