git.fiddlerwoaroof.com
Browse code

adding xmonad configuration

fiddlerwoaroof authored on 25/07/2014 08:32:09
Showing 2 changed files
1 1
new file mode 100644
2 2
Binary files /dev/null and b/.xmonad/cheatsheet.png differ
3 3
new file mode 100644
... ...
@@ -0,0 +1,239 @@
1
+import Control.Monad
2
+
3
+import Data.List
4
+import Data.Ratio ((%))
5
+
6
+import System.IO
7
+
8
+import XMonad hiding ( (|||) )
9
+import XMonad.Actions.CopyWindow(copy,copyWindow,kill1,killAllOtherCopies)
10
+import XMonad.Actions.DynamicWorkspaces
11
+import XMonad.Actions.GridSelect
12
+import XMonad.Actions.SpawnOn
13
+import XMonad.Core
14
+import XMonad.Hooks.DynamicLog
15
+import XMonad.Hooks.ManageDocks
16
+import XMonad.Layout.Accordion
17
+import XMonad.Layout.Circle
18
+import XMonad.Layout.Combo
19
+import XMonad.Layout.DragPane
20
+import XMonad.Layout.SubLayouts
21
+import XMonad.Layout.Gaps
22
+import XMonad.Layout.Grid
23
+import XMonad.Layout.IM
24
+import XMonad.Layout.LayoutCombinators
25
+import XMonad.Layout.BoringWindows hiding (Replace)
26
+import XMonad.Layout.NoBorders
27
+import XMonad.Layout.OneBig
28
+import XMonad.Layout.PerWorkspace
29
+import XMonad.Layout.Reflect
30
+import XMonad.Layout.Renamed
31
+import XMonad.Layout.ResizableTile
32
+import XMonad.Layout.Simplest
33
+import XMonad.Layout.Spiral
34
+import XMonad.Layout.Tabbed
35
+import XMonad.Layout.ThreeColumns
36
+import XMonad.Layout.TwoPane
37
+import XMonad.Layout.WindowNavigation
38
+import XMonad.Prompt
39
+import XMonad.StackSet as W
40
+import XMonad.StackSet hiding ( workspaces )
41
+import XMonad.Util.EZConfig(additionalKeys)
42
+import XMonad.Util.Loggers
43
+import XMonad.Util.Run(spawnPipe)
44
+
45
+nmaster = 1
46
+ratio = 13/21
47
+delta = 3/100
48
+tiled = Tall nmaster delta ratio
49
+myTabbed = renamed [Replace "Tabbed"] $ tabbedBottom shrinkText defaultTheme
50
+threeLayout = ThreeColMid nmaster delta ratio
51
+writingLayout = renamed [Replace "Writing"] $ gaps [(L,500), (R, 500)] Full
52
+
53
+imLayout = renamed [Replace "im"] $ withIM ratio empathyRoster Accordion where
54
+    ratio           = 1%6
55
+    empathyRoster   = And (ClassName "Empathy") (Role "contact_list")
56
+
57
+
58
+base =     mthree ||| wide ||| Full ||| Accordion ||| Circle ||| spiral (6/7)
59
+       ||| myTabbed ||| wideAccordion ||| writingLayout ||| rows ||| grid
60
+       ||| (TwoPane (3/100) (1/2)) ||| (OneBig (3/4) (3/4))
61
+   where
62
+      mthree = renamed [Replace "ThreeWide"] $ Mirror threeLayout
63
+      wide = renamed [Replace "Wide"] $ Mirror tiled
64
+      wideAccordion = renamed [Replace "WideAccordion"] $ Mirror Accordion
65
+      grid = renamed [Replace "Gridding"] $ GridRatio (1/2)
66
+      rows = renamed [Replace "WritingNew"] $ dragPane Vertical 1 0.5
67
+
68
+
69
+
70
+myLayout = avoidStruts $ smartBorders $
71
+   onWorkspace "web" myTabbed $
72
+   onWorkspace "terminal" tiled $
73
+   onWorkspace "IM" imLayout $
74
+   onWorkspace "images" (gimpLayout ||| tiled ||| threeLayout ||| base) $
75
+   tiled ||| threeLayout ||| base
76
+ where
77
+   gimpLayout = renamed [Replace "gimp"] $ withIM (11/64) (Role "gimp-toolbox") $ ResizableTall 2 (1/118) (11/20) [1]
78
+
79
+chooseLayout :: GSConfig String -> X ()
80
+chooseLayout conf = do
81
+   a <- gridselect conf $ makeLayoutList ["Tall", "ThreeCol", "Accordion", "Full", "Tabbed", "Spiral", "Wide", "ThreeWide", "WideAccordion", "Writing",
82
+                                          "WritingNew", "Gridding", "TwoPane", "OneBig"]
83
+   changeLayout a
84
+   return ()
85
+      where
86
+         makeLayoutList [] = []
87
+         makeLayoutList (l:ls) = (l,l):(makeLayoutList ls)
88
+         changeLayout a =
89
+            case a of
90
+               Just x -> sendMessage $ JumpToLayout x
91
+
92
+myPP = sjanssenPP {
93
+   ppCurrent = xmobarColor "grey" "white",
94
+   ppHidden = xmobarColor "red" "black",
95
+   ppHiddenNoWindows = id,
96
+   ppTitle = xmobarColor "green" "" . shorten 110
97
+}
98
+
99
+myManageHook = composeAll
100
+   [
101
+   (role =? "gimp-toolbox" <||> role =? "gimp-image-winow") --> (ask >>= doF . W.sink)
102
+   , className =? "X-terminal-emulator"      --> doCopy "terminal"
103
+   , className =? "Xmessage"  --> doFloat
104
+   , className =? "Qasmixer" --> doFloat
105
+   , className =? "Sonata" --> doFloat
106
+   , className =? "feh" --> viewShift "images"
107
+   , className =? "Display.im6" --> viewShift "images"
108
+   , manageDocks
109
+   ]
110
+ where role = stringProperty "WM_WINDOW_ROLE"
111
+
112
+
113
+doCopy :: WorkspaceId -> ManageHook
114
+doCopy i = doF . copyWin i =<< ask
115
+copyWin i a = copyWindow a i
116
+
117
+viewShift = doF . liftM2 (.) W.greedyView W.shift
118
+
119
+copyNSwitch windows target = do
120
+  windows $ copy target
121
+  windows $ W.greedyView target
122
+
123
+shiftNSwitch windows target = do
124
+  windows $ shift target
125
+  windows $ W.greedyView target
126
+
127
+main = do
128
+   xmproc <- spawnPipe "/home/edwlan/.cabal/bin/xmobar /home/edwlan/.xmobarrc"
129
+   xmonad $ defaultConfig
130
+      {
131
+         manageHook = myManageHook <+> manageSpawn <+> manageHook defaultConfig,
132
+         layoutHook = myLayout,
133
+         logHook = dynamicLogWithPP myPP {
134
+            ppOutput = hPutStrLn xmproc
135
+         },
136
+         modMask = mod4Mask,
137
+         focusFollowsMouse = False,
138
+         XMonad.workspaces = ["|", "web", "terminal", "1", "2", "3", "4", "5", "6", "images", "IM"]
139
+      } `additionalKeys` (
140
+      [
141
+         (((mod4Mask .|. controlMask, xK_q     ),
142
+               spawn "if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi")),
143
+
144
+         ((mod4Mask .|. controlMask .|. shiftMask, xK_h ), sendMessage $ Move L),
145
+         ((mod4Mask .|. controlMask .|. shiftMask, xK_j ), sendMessage $ Move D),
146
+         ((mod4Mask .|. controlMask .|. shiftMask, xK_k   ), sendMessage $ Move U),
147
+         ((mod4Mask .|. controlMask .|. shiftMask, xK_l), sendMessage $ Move R),
148
+         ((mod4Mask .|. controlMask, xK_k), killAllOtherCopies),
149
+         ((mod4Mask .|. controlMask, xK_m), withWorkspace defaultXPConfig (windows . shift)),
150
+
151
+         ((mod4Mask, numPadKeys !! 1), windows $ W.greedyView "web" ),
152
+         ((mod4Mask, numPadKeys !! 2), windows $ W.greedyView "terminal" ),
153
+         ((mod4Mask, numPadKeys !! 3), windows $ W.greedyView "1" ),
154
+         ((mod4Mask, numPadKeys !! 4), windows $ W.greedyView "2" ),
155
+         ((mod4Mask, numPadKeys !! 5), windows $ W.greedyView "3" ),
156
+         ((mod4Mask, numPadKeys !! 6), windows $ W.greedyView "4" ),
157
+         ((mod4Mask, numPadKeys !! 7), windows $ W.greedyView "5" ),
158
+         ((mod4Mask, numPadKeys !! 8), windows $ W.greedyView "6" ),
159
+         ((mod4Mask, numPadKeys !! 9), windows $ W.greedyView "images" ),
160
+
161
+         ((mod4Mask .|. shiftMask, numPadKeys !! 1), copyNSwitch windows "web" ),
162
+         ((mod4Mask .|. shiftMask, numPadKeys !! 2), copyNSwitch windows "terminal" ),
163
+         ((mod4Mask .|. shiftMask, numPadKeys !! 3), copyNSwitch windows "1" ),
164
+         ((mod4Mask .|. shiftMask, numPadKeys !! 4), copyNSwitch windows "2" ),
165
+         ((mod4Mask .|. shiftMask, numPadKeys !! 5), copyNSwitch windows "3" ),
166
+         ((mod4Mask .|. shiftMask, numPadKeys !! 6), copyNSwitch windows "4" ),
167
+         ((mod4Mask .|. shiftMask, numPadKeys !! 7), copyNSwitch windows "5" ),
168
+         ((mod4Mask .|. shiftMask, numPadKeys !! 8), copyNSwitch windows "6" ),
169
+         ((mod4Mask .|. shiftMask, numPadKeys !! 9), copyNSwitch windows "images" ),
170
+
171
+         ((mod4Mask .|. controlMask, numPadKeys !! 1), shiftNSwitch windows "web" ),
172
+         ((mod4Mask .|. controlMask, numPadKeys !! 2), shiftNSwitch windows "terminal" ),
173
+         ((mod4Mask .|. controlMask, numPadKeys !! 3), shiftNSwitch windows "1" ),
174
+         ((mod4Mask .|. controlMask, numPadKeys !! 4), shiftNSwitch windows "2" ),
175
+         ((mod4Mask .|. controlMask, numPadKeys !! 5), shiftNSwitch windows "3" ),
176
+         ((mod4Mask .|. controlMask, numPadKeys !! 6), shiftNSwitch windows "4" ),
177
+         ((mod4Mask .|. controlMask, numPadKeys !! 7), shiftNSwitch windows "5" ),
178
+         ((mod4Mask .|. controlMask, numPadKeys !! 8), shiftNSwitch windows "6" ),
179
+         ((mod4Mask .|. controlMask, numPadKeys !! 9), shiftNSwitch windows "images" ),
180
+
181
+         ((mod4Mask .|. shiftMask, xK_1), copyNSwitch windows "web" ),
182
+         ((mod4Mask .|. shiftMask, xK_2), copyNSwitch windows "terminal" ),
183
+         ((mod4Mask .|. shiftMask, xK_3), copyNSwitch windows "1" ),
184
+         ((mod4Mask .|. shiftMask, xK_4), copyNSwitch windows "2" ),
185
+         ((mod4Mask .|. shiftMask, xK_5), copyNSwitch windows "3" ),
186
+         ((mod4Mask .|. shiftMask, xK_6), copyNSwitch windows "4" ),
187
+         ((mod4Mask .|. shiftMask, xK_7), copyNSwitch windows "5" ),
188
+         ((mod4Mask .|. shiftMask, xK_8), copyNSwitch windows "6" ),
189
+         ((mod4Mask .|. shiftMask, xK_9), copyNSwitch windows "images" ),
190
+
191
+         ((mod4Mask .|. controlMask, xK_1), shiftNSwitch windows "web" ),
192
+         ((mod4Mask .|. controlMask, xK_2), shiftNSwitch windows "terminal" ),
193
+         ((mod4Mask .|. controlMask, xK_3), shiftNSwitch windows "1" ),
194
+         ((mod4Mask .|. controlMask, xK_4), shiftNSwitch windows "2" ),
195
+         ((mod4Mask .|. controlMask, xK_5), shiftNSwitch windows "3" ),
196
+         ((mod4Mask .|. controlMask, xK_6), shiftNSwitch windows "4" ),
197
+         ((mod4Mask .|. controlMask, xK_7), shiftNSwitch windows "5" ),
198
+         ((mod4Mask .|. controlMask, xK_8), shiftNSwitch windows "6" ),
199
+         ((mod4Mask .|. controlMask, xK_9), shiftNSwitch windows "images" ),
200
+
201
+         ((mod4Mask, xK_1), windows $ W.greedyView "web" ),
202
+         ((mod4Mask, xK_2), windows $ W.greedyView "terminal" ),
203
+         ((mod4Mask, xK_3), windows $ W.greedyView "1" ),
204
+         ((mod4Mask, xK_4), windows $ W.greedyView "2" ),
205
+         ((mod4Mask, xK_5), windows $ W.greedyView "3" ),
206
+         ((mod4Mask, xK_6), windows $ W.greedyView "4" ),
207
+         ((mod4Mask, xK_7), windows $ W.greedyView "5" ),
208
+         ((mod4Mask, xK_8), windows $ W.greedyView "6" ),
209
+         ((mod4Mask, xK_9), windows $ W.greedyView "images" ),
210
+         ((mod4Mask, xK_grave), windows $ W.greedyView "IM" ),
211
+
212
+         ((mod4Mask .|. shiftMask, xK_BackSpace), removeWorkspace),
213
+         ((mod4Mask .|. shiftMask, xK_k), kill1),
214
+         ((mod4Mask .|. shiftMask, xK_m), withWorkspace defaultXPConfig (windows . copy)),
215
+         ((mod4Mask .|. shiftMask, xK_n), addWorkspacePrompt defaultXPConfig),
216
+         ((mod4Mask .|. shiftMask, xK_Return), spawnHere "/usr/bin/x-terminal-emulator"),
217
+         ((mod4Mask .|. shiftMask, xK_r), renameWorkspace defaultXPConfig),
218
+         ((mod4Mask .|. shiftMask, xK_w), gridselectWorkspace defaultGSConfig (\ws -> greedyView ws . shift ws)),
219
+         ((mod4Mask, xK_b), sendMessage ToggleStruts),
220
+         ((mod4Mask, xK_g), goToSelected defaultGSConfig),
221
+         ((mod4Mask, xK_KP_Subtract), spawn "/usr/bin/zsh /home/edwlan/bin/dmenu_queueplay_mpd"),
222
+         ((mod4Mask, xK_KP_Multiply), spawn "/usr/bin/zsh /home/edwlan/bin/dmenu_queue_mpd"),
223
+         ((mod4Mask, xK_KP_Divide), spawn "/usr/bin/zsh /home/edwlan/bin/dmenu_play_mpd"),
224
+         ((mod4Mask, xK_KP_Add), spawn "/usr/bin/zsh /home/edwlan/bin/dzen_mpc_status"),
225
+         ((mod4Mask, xK_p), spawnHere "/usr/bin/dmenu_run -f"),
226
+
227
+         ((mod4Mask, xK_q), ((withSelectedWindow $ windows . W.focusWindow) defaultGSConfig) >> (windows $ W.shiftMaster)),
228
+         ((mod4Mask, xK_semicolon), chooseLayout defaultGSConfig),
229
+         ((mod4Mask, xK_w), gridselectWorkspace defaultGSConfig (\ws -> greedyView ws))
230
+      ] ++ zip (zip (repeat (mod4Mask)) ([xK_0])) (map (withNthWorkspace greedyView) [0..]) ++
231
+         zip (zip (repeat (mod4Mask .|. shiftMask)) ([xK_0])) (map (withNthWorkspace copy) [0..]) 
232
+         ++ zip (zip (repeat (mod4Mask)) (map (numPadKeys !!) ([0]))) (map (withNthWorkspace greedyView) [0..])
233
+      )
234
+
235
+numPadKeys = [xK_KP_Insert -- 0
236
+             , xK_KP_End,  xK_KP_Down,  xK_KP_Page_Down -- 1, 2, 3
237
+             , xK_KP_Left, xK_KP_Begin, xK_KP_Right     -- 4, 5, 6
238
+             , xK_KP_Home, xK_KP_Up,    xK_KP_Page_Up   -- 7, 8, 9
239
+             ]