stdin

  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
-- -*- haskell -*-
import Monad (liftM)
import XMonad hiding ( (|||) )
import XMonad.Core
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Hooks.DynamicLog hiding (shorten)
{-import XMonad.Hooks.ManageHelpers-}
import XMonad.Actions.CycleWS
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
import XMonad.Actions.DwmPromote
import XMonad.Actions.UpdatePointer
import XMonad.Actions.WindowGo
{-import XMonad.Actions.WindowNavigation-}
import XMonad.Hooks.UrgencyHook
import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm, spawnPipe)
import System.IO
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.RunOrRaise
import XMonad.Util.WorkspaceCompare
import XMonad.Util.EZConfig
import XMonad.Actions.Warp
{-import Data.Ratio-}
import Graphics.X11.Xlib.Extras
import Foreign.C.Types (CLong)
import XMonad.Actions.TagWindows
import XMonad.Layout.IM
import Data.Ratio ((%))
import XMonad.Layout.PerWorkspace
{-import XMonad.Layout.LayoutHints (layoutHints)-}
import XMonad.Layout.NoBorders
import XMonad.Layout.DragPane (dragPane, DragType(..))
import XMonad.Layout.Gaps
{-import XMonad.Layout.ToggleLayouts-}
import XMonad.Layout.Tabbed
import XMonad.Layout.ResizableTile
import XMonad.Layout.Grid
import XMonad.Layout.Magnifier
import XMonad.Layout.WindowNavigation
import XMonad.Layout.Named
import XMonad.Layout.LayoutCombinators
{-import XMonad.Layout.TabBarDecoration-}
import XMonad.Util.NamedScratchpad
import XMonad.Util.NamedWindows (getName)
import Data.List
import Data.Char
import XMonad.Hooks.ManageHelpers
role :: Query String
role = stringProperty "WM_WINDOW_ROLE"
notFloating :: Query Bool
notFloating = ask >>= \w -> liftX $ withWindowSet $ return . not . M.member w . W.floating
myTerminal = "urxvt"
myBorderWidth = 1
myModMask = mod4Mask
myNumlockMask = mod2Mask
myWorkspaces = ["web", "work" ,"chat", "mics"]
myNormalBorderColor = "#555555"
myFocusedBorderColor = "black"
----------Key bindings
myKeys = \conf -> mkKeymap conf $
[ ("M-S-<Return>", spawn $ XMonad.terminal conf)
, ("M-<F1>", runOrRaisePrompt defaultXPConfig)
, ("M-C-<Esc>", spawn $ "xkill")
, ("M-<Space>", sendMessage NextLayout)
, ("M-S-<Space>", setLayout $ XMonad.layoutHook conf)
, ("M-<Tab>", windows W.focusDown)
, ("M-j", windows W.focusDown)
, ("M-S-<Tab>", windows W.focusUp)
, ("M-k", windows W.focusUp)
, ("M-m", windows W.focusMaster)
, ("M-S-k", windows W.swapDown)
, ("M-S-j", windows W.swapUp)
, ("M-b", sendMessage $ ToggleGaps)
, ("M-h", sendMessage Shrink)
, ("M-l", sendMessage Expand)
, ("M-x t", withFocused $ windows . W.sink)
, ("M-,", sendMessage (IncMasterN 1))
, ("M-.", sendMessage (IncMasterN (-1)))
, ("M-S-q", io (exitWith ExitSuccess))
, ("M-q", restart "xmonad" True)
, ("M-p", shellPrompt defaultXPConfig)
, ("M-C-<Left>", prevNonEmptyWS )
, ("M-C-k", prevNonEmptyWS )
, ("M-C-<Right>", nextNonEmptyWS )
, ("M-C-j", nextNonEmptyWS )
, ("M-a", sendMessage MirrorShrink)
, ("M-y", sendMessage MirrorExpand)
, ("M-<Return>", dwmpromote)
, ("M-x M-c", kill)
, ("M-x c", kill)
, ("M-x e", spawn "emacsclient -c -s emacs")
, ("<XF86HomePage>", ror "firefox-beta" (className =? "Firefox"))
, ("<XF86Mail>", ror "krusader" (className =? "Krusader"))
, ("M-w", sendMessage MagnifyMore)
, ("M-e", sendMessage MagnifyLess)
, ("M-<", warpToWindow (1%10) (1%10)) -- Move pointer to currently focused window
, ("M-<XF86Calculator>", namedScratchpadAction scratchpads "ncmpcpp")
, ("M-<XF86Forward>", namedScratchpadAction scratchpads "rtorrent")
, ("M-<XF86Back>", namedScratchpadAction scratchpads "htop")
, ("M-<XF86Explorer>", namedScratchpadAction scratchpads "notes")
, ("<XF86Calculator>", windows (W.view "web"))
, ("<XF86Forward>", windows (W.view "work"))
, ("<XF86Back>", windows (W.view "chat"))
, ("<XF86Explorer>", windows (W.view "mics"))
, ("<XF86AudioRaiseVolume>", spawn "amixer sset \"PCM\" 5+")
, ("<XF86AudioLowerVolume>", spawn "amixer sset \"PCM\" 5-")
, ("M-<XF86AudioRaiseVolume>", spawn "amixer sset \"PCM Headphone\" 5+")
, ("M-<XF86AudioLowerVolume>", spawn "amixer sset \"PCM Headphone\" 5-")
, ("<Scroll_lock>", spawn "xset led 3")
, ("C-<Scroll_lock>", spawn "xset -led 3")
, ("<XF86AudioPlay>", spawn "ncmpcpp play")
, ("<XF86AudioStop>", spawn "ncmpcpp pause")
, ("M-<Left>", sendMessage $ Go L)
, ("M-<Right>", sendMessage $ Go R)
, ("M-<Up>", sendMessage $ Go U)
, ("M-<Down>", sendMessage $ Go D)
, ("M-S-<R>", sendMessage $ Swap R)
, ("M-S-<L>", sendMessage $ Swap L)
, ("M-S-<U>", sendMessage $ Swap U)
, ("M-S-<D>", sendMessage $ Swap D)
, ("<Pause>", unsafeSpawn "import -w root png:$HOME/screenshot--`date +%F--%T`.png")
, ("M-f", sendMessage $ JumpToLayout "full")
, ("M-t", sendMessage $ JumpToLayout "tabs")
, ("<XF86Sleep>", spawn "sudo /sbin/halt")
, ("<XF86Favorites>", spawn "emacsclient -c")
]
++
[ (m ++ i, windows $ f j)
| (i, j) <- zip (map show [1..9]) (XMonad.workspaces conf)
, (m, f) <- [("M-", W.view), ("M-S-", W.shift)]
]
where
nextNonEmptyWS = moveTo Next (WSIs (liftM (not .) isVisible))
prevNonEmptyWS = moveTo Prev (WSIs (liftM (not .) isVisible))
ror x p = runOrRaise x (p <&&> notFloating)
isVisible :: X (WindowSpace -> Bool)
isVisible = do
vs <- gets (map (W.tag . W.workspace) . W.visible . windowset)
return (\w -> (W.tag w) `elem` vs)
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
-- mod-button1, Set the window to floating mode and move by dragging
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
-- mod-button2, Raise the window to the top of the stack
, ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
-- mod-button3, 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)
-- cycle focus
, ((modMask, button4), (\_ -> windows W.focusUp))
, ((modMask, button5), (\_ -> windows W.focusDown))
-- cycle through workspaces
, ((controlMask .|. modMask, button5), nextNonEmptyWS)
, ((controlMask .|. modMask, button4), prevNonEmptyWS)
]
where
nextNonEmptyWS = \_ -> moveTo Next (WSIs (liftM (not .) isVisible))
prevNonEmptyWS = \_ -> moveTo Prev (WSIs (liftM (not .) isVisible))
myLayout = windowNavigation
$ onWorkspace "web" (tabsL
||| fullL
)
$ onWorkspace "mics" (tabsL
||| magL
||| tallL
)
$ onWorkspace "chat" (imL)
$ onWorkspace "work" (tabsL
||| tallL
||| fullL
)
$ onWorkspace "full" fullL
$ tallL
where
bscL = ResizableTall 1 (3 % 1000) (8 % 13) []
tallL= gaps [(U,18), (D,20)] $ bscL
fullL = named "full" $ noBorders Full
imL = named "im" $ gaps [(U,18), (D,20)] $ withIM (1%7) (Role "roster") Grid
tabsL =named "tabs" $ gaps [(U,18), (D,20)] $ tabbed shrinkText oxyTheme
magL = gaps [(U,18), (D,20)] $ magnifiercz (10%15) Grid
-- Configuration for Tabbed
oxyTheme :: Theme
oxyTheme = defaultTheme { inactiveBorderColor = "#696969"
, activeBorderColor = "white"
, activeColor = "#111111"
, inactiveColor = "#212121"
, inactiveTextColor = "#696969"
, activeTextColor = "white"
, fontName = "xft:Terminus-10"
, decoHeight = 18
, urgentColor = "white"
, urgentTextColor = "#77e000"
}
--SendMessage on app up
fromWindowOp :: (Window -> X()) -> ManageHook
fromWindowOp fn = ask >>= \w -> liftX (fn w) >> doF id
fromX :: X () -> ManageHook
fromX op = fromWindowOp $ const op
myManageHook = composeAll
[className =? "Firefox" --> doF (W.shift "web")
, className =? "Gajim.py" --> doF (W.shift "chat")
, className =? "MPlayer" --> doFullFloat
, className =? "Gwenview" --> doFullFloat
, className =? "Okular" --> doFullFloat
{-, className =? "Qutim" [>> doF (W.shift "chat")-}
, className =? "Krusader" --> doF (W.shift "work")
, resource =? "stalonetray" --> doIgnore
, className =? "Dialog" --> doFloat
, title =? "Add-ons" --> doFloat
, title =? "Copying" --> doFloat
, title =? "Downloads" --> doFloat
, title =? "Moving" --> doFloat]
<+> manageDocks
-- Statusbar with workspaces, layout and title
myStatusBar = "dzen2 -x 0 -y 0 -h 18 -ta l -fg '" ++ myDzenFGColor ++
"' -bg '" ++ myDzenBGColor ++ "' -fn '" ++ myFont ++ "' -w 720"
-- Colors, font and iconpath definitions:
myFont = "-*-terminus-*-*-*-*-12-*-*-*-*-*-*-*%"
myIconDir = "/home/kain/.dzen"
myDzenFGColor = "#555555"
myDzenBGColor = "#212121"
myNormalFGColor = "#77e000"
myNormalBGColor = "#000000"
myFocusedFGColor = "#f0f0f0"
myFocusedBGColor = "#333333"
myUrgentFGColor = "#0099ff"
myUrgentBGColor = "#991133"
mySeperatorColor = "#555555"
-- Status bars and logging
myLogHook h = defaultPP
{ ppCurrent = dzenColor myNormalFGColor myDzenBGColor . pad . ("^i(.dzen/corner.xbm)" ++) -- current workspace
, ppVisible = dzenColor "lightgreen" "" . pad -- visible workspaces on other screens
, ppHidden = dzenColor "white" "" . pad . ("^i(.dzen/corner.xbm)" ++) -- hidden workspaces with apps
, ppHiddenNoWindows = dzenColor "#444444" "" . pad -- empty workspaces
, ppUrgent = dzenColor "" myUrgentBGColor -- urgent workspaces
, ppTitle = dzenColor myNormalFGColor "" . pad . dzenEscape -- title of selected window
, ppWsSep = "" -- workspace seperator
, ppSep = dzenEscape "|" -- workspace/layout/title seperator
-- Layout icons
, ppLayout = dzenColor myNormalFGColor "" .
(\ x -> case x of
"tallL" -> pad "^i(/home/kain/.dzen/layout-tall-right.xbm)"
"Mirror Tall" -> pad "^i(/home/kain/.dzen/layout-mirror-bottom.xbm)"
"full" -> pad "^i(/home/kain/.dzen/layout-full.xbm)"
"im" -> pad "^i(/home/kain/.dzen/layout-withim-left1.xbm)"
"IM Hinted ResizableTall" -> pad "^i(/home/kain/.dzen/layout-withim-left2.xbm)"
"IM Mirror Hinted ResizableTall" -> pad "^i(/home/kain/.dzen/layout-withim-left3.xbm)"
"IM Full" -> pad "^i(/home/kain/.dzen/layout-withim-left4.xbm)"
"tabs" -> pad "^i(/home/kain/.dzen/tabs.xbm)"
_ -> pad x
)
, ppOutput = hPutStrLn h
}
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
-- 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 = do
spawn "/home/kain/.bin/autostart.sh"
--------------- Scratchpads
scratchpads = [ NS "notes" "urxvtc -name terminal" (resource =? "terminal") defaultRect
, NS "htop" "urxvt -name htop -e htop" (title =? "htop") defaultRect
, NS "ncmpcpp" "urxvt -name ncmpcpp -e ncmpcpp" (resource =? "ncmpcpp") smallerRect
, NS "rtorrent" "urxvt -name rtorrent -e dtach -A /tmp/rtorrent.dtach -z rtorrent" (resource =? "rtorrent") smallerRect
] where
defaultRect = Just $ W.RationalRect (1/6) (1/6) (2/3) (2/3)
smallerRect = Just $ W.RationalRect (1/4) (1/6) (1/2) (2/3)
calcRect = Just $ W.RationalRect (3/8) (1/3) (1/4) (1/3)
------------------------------------------------------------------------
{-$ withWindowNavigationKeys [((modMask, xK_Up) WnGo U),((modMask, xk_Down) WnGo D)]-}
--Main
main = do
dzen <- spawnPipe myStatusBar
xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
numlockMask = myNumlockMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook <+> (namedScratchpadManageHook scratchpads),
logHook = dynamicLogWithPP (myLogHook dzen)
,startupHook = myStartupHook
}