-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmonad.hs
251 lines (220 loc) · 11 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
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS -fno-warn-missing-signatures #-}
----------------------------------------------------------------------------
-- |
-- Module : XMonad.Config.Bluetile
-- Copyright : (c) Jan Vornberger 2009
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : [email protected]
-- Stability : unstable
-- Portability : not portable
--
-- This is the default configuration of Bluetile
-- (<http://projects.haskell.org/bluetile/>). If you
-- are migrating from Bluetile to xmonad or want to create
-- a similar setup, then this will give you pretty much
-- the same thing, except for Bluetile's helper applications
-- such as the dock.
--
-----------------------------------------------------------------------------
import XMonad hiding ( (|||) )
import XMonad.Layout.BorderResize
import XMonad.Layout.BoringWindows
import XMonad.Layout.ButtonDecoration
import XMonad.Layout.Decoration
import XMonad.Layout.DecorationAddons
import XMonad.Layout.DraggingVisualizer
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Maximize
import XMonad.Layout.Minimize
import XMonad.Layout.MouseResizableTile
import XMonad.Layout.Named
import XMonad.Layout.NoBorders
import XMonad.Layout.PositionStoreFloat
import XMonad.Layout.WindowSwitcherDecoration
import XMonad.Actions.BluetileCommands
import XMonad.Actions.CycleWS
import XMonad.Actions.Minimize
import XMonad.Actions.WindowMenu
import XMonad.Hooks.CurrentWorkspaceOnTop
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.PositionStoreHooks
import XMonad.Hooks.Minimize
import XMonad.Hooks.ServerMode
import XMonad.Hooks.WorkspaceByPos
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.WorkspaceHistory
import XMonad.Util.Font
import XMonad.Util.Replace
import XMonad.Util.Themes
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
import Data.Monoid
import Control.Monad(when)
-- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@:
--
-- > import XMonad
-- > import XMonad.Config.Bluetile
-- > import XMonad.Util.Replace
-- >
-- > main = replace >> xmonad bluetileConfig
--
-- The invocation of 'replace' will replace a currently running
-- window manager. This is the default behaviour of Bluetile as well.
-- See "XMonad.Util.Replace" for more information.
bluetileWorkspaces :: [String]
bluetileWorkspaces = ["1","2","3","4","5","6","7","8","9","0"]
bluetileKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
bluetileKeys conf@(XConfig {XMonad.modMask = modMask'}) = M.fromList $
-- launching and killing programs
[ ((modMask' , xK_Return), spawn $ XMonad.terminal conf) -- %! Launch terminal
, ((modMask' .|. shiftMask, xK_c ), kill) -- %! Close the focused window
, ((modMask', xK_F5 ), refresh) -- %! Resize viewed windows to the correct size
, ((modMask' .|. shiftMask, xK_F5 ), setLayout $ XMonad.layoutHook conf) -- %! Reset the layouts on the current workspace to default
, ((modMask', xK_o ), windowMenu)
-- move focus up or down the window stack
, ((modMask', xK_Tab ), focusDown) -- %! Move focus to the next window
, ((modMask' .|. shiftMask, xK_Tab ), focusUp) -- %! Move focus to the previous window
, ((modMask', xK_j ), focusDown) -- %! Move focus to the next window
, ((modMask', xK_k ), focusUp) -- %! Move focus to the previous window
, ((modMask', xK_space ), focusMaster) -- %! Move focus to the master window
-- modifying the window order
, ((modMask' .|. shiftMask, xK_space ), windows W.swapMaster) -- %! Swap the focused window and the master window
, ((modMask' .|. shiftMask, xK_j ), windows W.swapDown ) -- %! Swap the focused window with the next window
, ((modMask' .|. shiftMask, xK_k ), windows W.swapUp ) -- %! Swap the focused window with the previous window
-- resizing the master/slave ratio
, ((modMask', xK_h ), sendMessage Shrink) -- %! Shrink the master area
, ((modMask', xK_l ), sendMessage Expand) -- %! Expand the master area
, ((modMask', xK_u ), sendMessage ShrinkSlave) -- %! Shrink a slave area
, ((modMask', xK_i ), sendMessage ExpandSlave) -- %! Expand a slave area
-- floating layer support
, ((modMask', xK_t ), withFocused $ windows . W.sink) -- %! Push window back into tiling
, ((modMask' .|. shiftMask, xK_t ), withFocused $ float ) -- %! Float window
-- increase or decrease number of windows in the master area
, ((modMask' , xK_comma ), sendMessage (IncMasterN 1)) -- %! Increment the number of windows in the master area
, ((modMask' , xK_period), sendMessage (IncMasterN (-1))) -- %! Deincrement the number of windows in the master area
-- quit, or restart
, ((modMask' .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) -- %! Quit
, ((modMask' , xK_q ), restart "xmonad" True) -- %! Restart
-- Metacity-like workspace switching
, ((mod1Mask .|. controlMask, xK_Left), prevWS)
, ((mod1Mask .|. controlMask, xK_Right), nextWS)
, ((mod1Mask .|. controlMask .|. shiftMask, xK_Left), shiftToPrev >> prevWS)
, ((mod1Mask .|. controlMask .|. shiftMask, xK_Right), shiftToNext >> nextWS)
-- more Metacity keys
, ((mod1Mask , xK_F2), spawn "xfce4-appfinder") -- %! Launch Xfce "Run application" dialog
, ((mod1Mask , xK_F4), kill)
-- Switching to layouts
, ((modMask' , xK_a), sendMessage $ JumpToLayout "Floating")
, ((modMask' , xK_s), sendMessage $ JumpToLayout "Tiled1")
, ((modMask' , xK_d), sendMessage $ JumpToLayout "Tiled2")
, ((modMask' , xK_f), sendMessage $ JumpToLayout "Fullscreen")
-- Maximizing
, ((modMask' , xK_z), withFocused (sendMessage . maximizeRestore))
-- Minimizing
, ((modMask', xK_m ), withFocused minimizeWindow)
, ((modMask' .|. shiftMask, xK_m ), withLastMinimized maximizeWindowAndFocus)
, ((modMask', xK_x ), withLastMinimized maximizeWindowAndFocus)
]
++
-- mod-[1..9] ++ [0] %! Switch to workspace N
-- mod-shift-[1..9] ++ [0] %! 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} %! Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r} %! Move client to screen 1, 2, or 3
[((m .|. modMask', key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
bluetileMouseBindings :: XConfig Layout -> M.Map (KeyMask, Button) (Window -> X ())
bluetileMouseBindings (XConfig {XMonad.modMask = modMask'}) = M.fromList $
-- mod-button1 %! Move a floated window by dragging
[ ((modMask', button1), (\w -> isFloating w >>= \isF -> when (isF) $
focus w >> mouseMoveWindow w >> windows W.shiftMaster))
-- mod-button2 %! Switch to next and first layout
, ((modMask', button2), (\_ -> sendMessage NextLayout))
, ((modMask' .|. shiftMask, button2), (\_ -> sendMessage $ JumpToLayout "Floating"))
-- mod-button3 %! Resize a floated window by dragging
, ((modMask', button3), (\w -> isFloating w >>= \isF -> when (isF) $
focus w >> mouseResizeWindow w >> windows W.shiftMaster))
]
isFloating :: Window -> X (Bool)
isFloating w = do
ws <- gets windowset
return $ M.member w (W.floating ws)
solitaryTheme :: Theme
solitaryTheme =
def
{ activeColor = "#FFBB66",
inactiveColor = "#555555",
activeBorderColor = "#FFBB66",
inactiveBorderColor = "#111111",
activeTextColor = "black",
inactiveTextColor = "#EEEEEE",
--fontName = "-misc-fixed-*-*-*-*-18-*-*-*-*-*-iso8859-2",
fontName = "-misc-fixed-*-*-*-*-15-*-*-*-*-*-iso8859-2",
decoHeight = 20,
urgentColor = "red",
urgentTextColor = "black",
windowTitleAddons = [
(" (M)", AlignLeft),
("_" , AlignRightOffset 48),
("[]" , AlignRightOffset 25),
("X" , AlignRightOffset 10)
]
}
bluetileManageHook :: ManageHook
bluetileManageHook = composeAll
[ workspaceByPos, positionStoreManageHook (Just solitaryTheme)
, className =? "mpv" --> doFloat
, className =? "upc.exe" --> doFloat
, className =? "gamescope" --> doFloat
, className =? "Steam" --> doShift "8"
, className =? "Hexchat" --> doShift "2"
, className =? "Audacious" --> doShift "3"
, className =? "Transmission-gtk" --> doShift "3"
, className =? "Vivaldi-stable" --> doShift "4"
, className =? "org.remmina.Remmina" --> doShift "5"
, className =? "jetbrains-idea" --> doShift "6"
, isFullscreen --> doFullFloat]
bluetileLayoutHook = avoidStruts $ minimize $ boringWindows $ (
named "Tiled2" tiled2 |||
named "Tiled1" tiled1 |||
named "Floating" floating |||
named "Fullscreen" fullscreen
)
where
tiled2 = tilingDeco $ maximize $ mouseResizableTile
tiled1 = tilingDeco $ maximize $ mouseResizableTileMirrored
floating = floatingDeco $ maximize $ borderResize $ positionStoreFloat
fullscreen = tilingDeco $ maximize $ smartBorders Full
tilingDeco l = windowSwitcherDecorationWithButtons shrinkText solitaryTheme (draggingVisualizer l)
floatingDeco l = buttonDeco shrinkText solitaryTheme l
bluetileConfig =
docks $ setEwmhActivateHook doAskUrgent . ewmhFullscreen . ewmh $
def
{ modMask = mod4Mask, -- logo key
clickJustFocuses = False,
manageHook = bluetileManageHook,
layoutHook = bluetileLayoutHook,
logHook = currentWorkspaceOnTop >> workspaceHistoryHook,
handleEventHook = minimizeEventHook
`mappend` serverModeEventHook' bluetileCommands
`mappend` positionStoreEventHook,
workspaces = bluetileWorkspaces,
keys = bluetileKeys,
mouseBindings = bluetileMouseBindings,
focusFollowsMouse = False,
borderWidth = 0,
focusedBorderColor = "#101010",
normalBorderColor = "#FF7700",
terminal = "xfce4-terminal"
}
main = replace >> xmonad (bluetileConfig)