-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmonad.hs
executable file
·390 lines (349 loc) · 15.6 KB
/
xmonad.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
-- xmonad config used by Cassandra Comar
-- Author: Cassandra Comar
-- http://github.com/cassandracomar/dotxmonad
{-# LANGUAGE ViewPatterns #-}
import Control.Concurrent
import Control.Monad
import Data.Default
import Data.List (stripPrefix)
import qualified Data.Map as M
import Data.Maybe (fromJust)
import Graphics.X11.Xinerama
import System.Exit
import System.IO
import XMonad hiding (Connection, (|||))
import XMonad.Actions.Navigation2D
import XMonad.Actions.PhysicalScreens
import XMonad.Config.Xfce
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.InsertPosition
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Layout.IM
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.LayoutScreens
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Spacing
import XMonad.Layout.Tabbed
import XMonad.Layout.TwoPane
import XMonad.Layout.WindowNavigation
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig
import XMonad.Util.Run
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal = "emacsclient -c -e '(aweshell-new)'"
-- Width of the window border in pixels.
--
myBorderWidth = 3
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask = mod1Mask
-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
--
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
--
myWorkspaces = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", ""]
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor = "#3c2c1c"
myFocusedBorderColor = "#eedece"
myFont = "xft:Inconsolata-dz for Powerline:Medium:size=9"
background = "#181512"
foreground = "#D6C3B6"
myStatusBars sid horiz vert = do
infoBarSB <- statusBarPipe infoBar (return prettyPrinter)
return $ statusBarGeneric iconsBar mempty <> statusBarGeneric trayer mempty <> infoBarSB
where
iconsBar = "~/.xmonad/status_bar '" ++ foreground ++ "' '" ++ background ++ "' '" ++ myFont ++ "' '" ++ show (horiz + 2823) ++ "' '" ++ show vert ++ "'"
trayer = "trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand false --width 150 --widthtype request --transparent true --tint '" ++ background ++ "' --alpha 0 --height 40 --monitor '" ++ show sid ++ "'"
infoBar = "dzen2 -dock -e 'button2=;' -x '" ++ show horiz ++ "' -y '" ++ show vert ++ "' -h 40 -w 2823 -ta 'l' -fg '" ++ foreground ++ "' -bg '" ++ background ++ "' -fn '" ++ myFont ++ "'"
windowSpacing = 20
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys conf@XConfig {XMonad.modMask = modMask} =
M.fromList $
-- launch a terminal
[ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf),
((modMask .|. controlMask, xK_l), spawn "xscreensaver-command -lock"),
-- launch dmenu
((modMask, xK_p), spawn "CMD=$(/etc/profiles/per-user/cassandra/bin/yeganesh -x); dunstify $CMD; PATH=~/.local/bin/:$PATH nohup $CMD &"),
-- suspend the computer
((modMask, xK_g), spawn "sudo systemctl suspend"),
-- close focused window
((modMask .|. shiftMask, xK_c), kill),
-- Rotate through the available layout algorithms
((modMask, xK_space), sendMessage NextLayout),
((modMask, xK_b), sendMessage ToggleStruts),
-- Reset the layouts on the current workspace to default
((modMask .|. shiftMask, xK_space), setLayout $ XMonad.layoutHook conf),
-- Resize viewed windows to the correct size
((modMask, xK_n), refresh),
-- Move focus to the next window
((modMask, xK_Tab), windows W.focusDown),
-- Move focus to the next window
((modMask, xK_j), windows W.focusDown),
-- Move focus to the previous window
((modMask, xK_k), windows W.focusUp),
-- Move focus to the master window
((modMask, xK_m), windows W.focusMaster),
-- Swap the focused window and the master window
((modMask, xK_Return), windows W.swapMaster),
-- Swap the focused window with the next window
((modMask .|. shiftMask, xK_j), windows W.swapDown),
-- Swap the focused window with the previous window
((modMask .|. shiftMask, xK_k), windows W.swapUp),
-- Shrink the master area
((modMask, xK_h), sendMessage Shrink),
-- Expand the master area
((modMask, xK_l), sendMessage Expand),
-- Push window back into tiling
((modMask, xK_t), withFocused $ windows . W.sink),
-- Increment the number of windows in the master area
((modMask, xK_comma), sendMessage (IncMasterN 1)),
-- Deincrement the number of windows in the master area
((modMask, xK_period), sendMessage (IncMasterN (-1))),
((modMask .|. controlMask, xK_b), sendMessage $ JumpToLayout "IM Tabbed Simplest"),
((modMask .|. controlMask, xK_Up), sendMessage $ Move U),
((modMask .|. controlMask, xK_Down), sendMessage $ Move D),
((modMask .|. controlMask, xK_Right), sendMessage $ Move R),
((modMask .|. controlMask, xK_Left), sendMessage $ Move L),
((modMask .|. controlMask .|. shiftMask, xK_space), rescreen),
((modMask .|. shiftMask, xK_b), sendMessage ToggleStruts),
((mod4Mask, xK_Up), spawn "volume-adj.sh up"),
((mod4Mask, xK_Down), spawn "volume-adj.sh down"),
((mod4Mask .|. shiftMask, xK_space), spawn "volume-adj.sh mute"),
((mod4Mask, xK_space), spawn "mpc toggle"),
((mod4Mask, xK_Right), spawn "mpc next"),
((mod4Mask, xK_Left), spawn "mpc prev"),
((mod4Mask .|. shiftMask, xK_Right), spawn "playerctl position 5+"),
((mod4Mask .|. shiftMask, xK_Left), spawn "playerctl position 5-"),
((mod4Mask, xK_Return), spawn "/home/cassandra/.files/music"),
((mod4Mask, xK_b), spawn "/home/cassandra/.files/launch-dwb"),
((modMask, xK_m), spawn "mpdmenu"),
((mod4Mask, xK_i), spawn "sakura -t 'IRC' -x '/home/cassandra/.files/connect-irssi'"),
-- Quit xmonad
((modMask .|. shiftMask, xK_q), io exitSuccess),
-- Restart xmonad
((modMask, xK_q), rescreen >> restart "xmonad" True)
]
++
--
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
--
[ ((m .|. modMask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [xK_0]),
(f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
]
++
--
-- mod-{w,e,r,s,d,f}, Switch to physical/Xinerama screens 1, 2, 3, 4, 5, or 6
-- mod-shift-{w,e,r,s,d,f}, Move client to screen 1, 2, 3, 4, 5, or 6
--
[ ((mask .|. modMask, key), f sc)
| (key, sc) <- zip [xK_w, xK_e, xK_r, xK_s, xK_d, xK_f] [0 ..],
(f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]
]
------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings XConfig {XMonad.modMask = modMask} =
M.fromList
-- alt-left click, Set the window to floating mode and move by dragging
[ ((modMask, button1), \w -> focus w >> mouseMoveWindow w),
-- alt-middle click, Raise the window to the top of the stack
((modMask, button2), \w -> focus w >> windows W.swapMaster),
-- alt-right click, Set the window to floating mode and resize by dragging
((modMask, button3), \w -> focus w >> mouseResizeWindow w)
-- you may also bind events to the mouse scroll wheel (button4 and button5)
]
------------------------------------------------------------------------
-- Layouts:
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
--
myTabConfig =
def
{ activeBorderColor = myFocusedBorderColor,
activeTextColor = foreground,
activeColor = background,
inactiveBorderColor = myNormalBorderColor,
inactiveTextColor = "#a39383",
inactiveColor = background,
fontName = myFont,
decoHeight = 40
}
myLayout = avoidStruts . modifySpecifics $ tabbedLayout ||| spacedLayout ||| codingLayout
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
tiled2 = Tall nmaster delta ratio2
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1 / 2
ratio2 = 7 / 8
-- Percent of screen to increment by when resizing panes
delta = 3 / 100
-- IM Pane size
imratio = 3 / 16
withMyIM = withIM imratio (Title "Buddy List")
-- Layout pieces
uniformBorder i = Border i i i i
spacedLayout = spacingRaw True (uniformBorder 0) False (uniformBorder windowSpacing) True . windowNavigation $ tiled
tabbedLayout = windowNavigation $ tabbed shrinkText myTabConfig
codingLayout = windowNavigation $ Mirror tiled2 ****|*** tabbed shrinkText myTabConfig
-- Workspace-specific layouts.
imWorkspace = onWorkspace "III" $ withMyIM tabbedLayout
codingWorkspace = onWorkspace "I" $ tabbedLayout ||| codingLayout
terminalWorkspace = onWorkspace "IV" spacedLayout
modifySpecifics = imWorkspace . codingWorkspace . terminalWorkspace
------------------------------------------------------------------------
-- Window rules:
-- Execute arbitrary actions and WindowSet manipulations when managing
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook =
composeAll
[ className =? "Psx.real" --> doFloat,
className =? "feh" --> doFloat,
title =? "About Aurora" --> doFloat,
title =? "Software Update" --> doFloat,
title =? "Rename Bookmark Item" --> doRectFloat (W.RationalRect (3 / 8) (7 / 16) (1 / 4) (1 / 8)),
title =? "MUSIC" --> doRectFloat (W.RationalRect (1 / 4) (1 / 4) (1 / 2) (1 / 2)),
title =? "FILES" --> doRectFloat (W.RationalRect (1 / 4) (1 / 4) (1 / 2) (1 / 2)),
title =? "Print" --> doRectFloat (W.RationalRect (1 / 4) (1 / 4) (1 / 2) (1 / 2)),
title =? "IRC" --> doShift "III",
title =? "Signal" --> doShift "III",
className =? "Gvim" --> doShift "I",
className =? "firefox" --> doShift "II",
className =? "Clementine" --> doShift "V",
className =? "Ario" --> doShift "V",
className =? "VirtualBox" --> doShift "IX",
className =? "Slack" --> doShift "III",
className =? "Riot" --> doShift "III",
className =? "discord" --> doShift "III",
className =? "Signal" --> doShift "III",
resource =? "desktop_window" --> doIgnore,
resource =? "kdesktop" --> doIgnore,
resource =? "steam" --> doIgnore,
resource =? "discord" --> doShift "III",
resource =? "signal" --> doShift "III",
title =? "helm" --> doFloat,
isFullscreen --> (doF W.focusDown <+> doFullFloat)
]
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
wrapWorkspaceClickable :: String -> String
wrapWorkspaceClickable s = wrap ("^ca(1, xdotool key alt+" ++ show (romanToInt s) ++ ")") "^ca()" s
prettyPrinter :: PP
prettyPrinter =
def
{ ppTitle = dzenColor foreground background,
ppCurrent = dzenColor "#f5e3d5" background . wrapWorkspaceClickable,
ppVisible = dzenColor "#d4c4b4" background . wrapWorkspaceClickable,
ppHidden = dzenColor "#a39383" background . wrapWorkspaceClickable,
ppHiddenNoWindows = dzenColor "#716151" background . wrapWorkspaceClickable,
ppUrgent = dzenColor "#D23D3D" background . wrapWorkspaceClickable,
ppLayout = dzenColor foreground background . fixLayoutName,
ppOrder = id,
ppSep = " | "
}
romanToInt :: String -> Int
romanToInt = fst . foldr ((\p (t, s) -> if p >= s then (t + p, p) else (t - p, p)) . fromJust . flip lookup (zip "IVXLCDM" [1, 5, 10, 50, 100, 500, 1000])) (0, 0)
fixLayoutName :: String -> String
fixLayoutName (stripPrefix "IM " -> Just s) = fixLayoutName s
fixLayoutName (stripPrefix "SmartSpacing 20 " -> Just s) = fixLayoutName s
fixLayoutName "Tabbed Simplest" = "Tabbed"
fixLayoutName "combining Mirror Tall and Tabbed Simplest with Tall" = "Coding"
fixLayoutName s = s
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
statusBars :: ScreenId -> IO StatusBarConfig
statusBars sid' = do
let sid = fromInteger $ toInteger sid'
dpy <- openDisplay ""
rects <- getScreenInfo dpy
let x0 = rect_x $ rects !! sid
let y0 = rect_y $ rects !! sid
closeDisplay dpy
myStatusBars sid' x0 y0
------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook = setWMName "LG3D"
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
-- Run xmonad with the settings you specify. No need to modify this.
main =
xmonad . ewmh . dynamicEasySBs statusBars $
xfceConfig
{ -- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = avoidStruts $ smartBorders myLayout,
manageHook = manageDocks <+> insertPosition Above Newer <+> myManageHook,
startupHook = myStartupHook,
logHook = fadeInactiveLogHook 0xdddddddd
}
`additionalKeysP` [ ("<XF86MonBrightnessDown>", spawn "~/.files/backlight-adj.sh down"),
("<XF86MonBrightnessUp>", spawn "~/.files/backlight-adj.sh up"),
("<XF86AudioMute>", spawn "~/.files/volume-adj.sh mute"),
("<XF86AudioLowerVolume>", spawn "~/.files/volume-adj.sh down"),
("<XF86AudioRaiseVolume>", spawn "~/.files/volume-adj.sh up"),
("<XF86AudioPrev>", spawn "playerctl previous"),
("<XF86AudioPlay>", spawn "playerctl play-pause"),
("<XF86AudioNext>", spawn "playerctl next")
]
------------------------------------------------------------------------