aboutsummaryrefslogtreecommitdiffstats
path: root/xmonad/xmonad.hs.gpp
blob: 7a6f9606df71ae62c9bfed3ec3f413a9ca82e0c8 (plain) (blame)
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
-- -*- haskell -*-
import XMonad hiding ( (|||) )
import qualified XMonad.StackSet as W -- hiding ( workspaces, focus )

import XMonad.Actions.CycleWS
import XMonad.Actions.UpdatePointer
import XMonad.Actions.MouseResize
import XMonad.Actions.WindowMenu

import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.EwmhDesktops

import XMonad.Layout.IM
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.LayoutHints
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.ResizableTile
import XMonad.Layout.Grid
import XMonad.Layout.Accordion
import XMonad.Layout.Circle
import XMonad.Layout.WindowArranger
import XMonad.Layout.SimpleFloat
import XMonad.Layout.PerScreen
import XMonad.Layout.LayoutModifier
import XMonad.Layout.Gaps

import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.Run
import XMonad.Util.Scratchpad
import XMonad.Util.WindowProperties
import XMonad.Util.WorkspaceCompare
import XMonad.Util.Replace
import XMonad.Util.Themes

import XMonad.Layout.Tabbed
import XMonad.Layout.DecorationMadness
import XMonad.Layout.DecorationAddons
import XMonad.Layout.Decoration
import XMonad.Layout.SimpleDecoration
import XMonad.Layout.DwmStyle
import XMonad.Layout.TabBarDecoration
import XMonad.Layout.ImageButtonDecoration
import XMonad.Layout.BorderResize
import XMonad.Layout.SimpleFloat
import XMonad.Layout.Maximize
import XMonad.Layout.Minimize

import qualified Data.Map as M


$$<
	hostname="$(hostname | tr '[[:upper:]]' '[[:lower:]]')"

	workspace_1=main
	if test "$hostname" = zenith; then
		workspace_7=chat
		workspace_8=mail
		workspace_9=media
	else
		workspace_9=off
	fi

	modmask=mod4Mask # Super_L
	focus_on_hover=True
	with_decorations=true

	if test -x /usr/bin/terminator || test -x /usr/local/bin/terminator; then
		terminal=terminator
	elif test -x /usr/bin/st || test -x /usr/local/bin/st; then
		terminal=st
	else
		terminal=xterm
	fi
	screenshooter=
$$>



---- ==== Keypad numbers ==== ----
numPadKeys = [ xK_KP_Insert                             -- 0
             , xK_KP_End,  xK_KP_Down,  xK_KP_Page_Down -- 1, 2, 3
             , xK_KP_Left, xK_KP_Begin, xK_KP_Right     -- 4, 5, 6
             , xK_KP_Home, xK_KP_Up,    xK_KP_Page_Up   -- 7, 8, 9
             ]


---- ==== Kill panel and restart ==== ----
$$>if test -x /usr/bin/dpkill; then
myRestart = "env DISPLAY=${DISPLAY}.0 dpkill xpybar ; xmonad --restart"
$$>else
myRestart = "pkill xpybar ; xmonad --restart"
$$>fi


---- ==== Naming of workspaces ==== ---- 
myWorkspaces = [ "1$${workspace_1:+-${workspace_1}}"
               , "2$${workspace_2:+-${workspace_2}}"
               , "3$${workspace_3:+-${workspace_3}}"
               , "4$${workspace_4:+-${workspace_4}}"
               , "5$${workspace_5:+-${workspace_5}}"
               , "6$${workspace_6:+-${workspace_6}}"
               , "7$${workspace_7:+-${workspace_7}}"
               , "8$${workspace_8:+-${workspace_8}}"
               , "9$${workspace_9:+-${workspace_9}}"
               ]


---- ==== Mouse bindings ==== ----
stackRotate (W.Stack f [] rs) = W.Stack f [] rs
stackRotate (W.Stack f ls rs) = W.Stack l (f:(reverse ls')) rs
                              where
                                (l:ls') = reverse ls

stackUnrotate (W.Stack f [] rs)     = W.Stack f [] rs
stackUnrotate (W.Stack f (l:ls) rs) = W.Stack l (ls ++ [f]) rs

stackUnrotateRight (W.Stack f ls []) = W.Stack f ls []
stackUnrotateRight (W.Stack f ls rs) = W.Stack r ls (f:(reverse rs'))
                                     where
                                       (r:rs') = reverse rs

stackRotateRight (W.Stack f ls [])     = W.Stack f ls []
stackRotateRight (W.Stack f ls (r:rs)) = W.Stack r ls (rs ++ [f])

myMouse = [ (( $${modmask}, button4), (\w -> focus w >> windows (W.modify' stackRotate)))
          , (( $${modmask}, button5), (\w -> focus w >> windows (W.modify' stackUnrotate)))
          , (( $${modmask} .|. controlMask, button4), (\w -> focus w >> windows (W.modify' stackRotateRight)))
          , (( $${modmask} .|. controlMask, button5), (\w -> focus w >> windows (W.modify' stackUnrotateRight)))
          ]


---- ==== Main method ==== ---- 
main = do
  ---- System status panel
  d <- spawnPipe "env DISPLAY=${DISPLAY}.0 xpybar -c ~/.config/xpybar/xmonad-monitor"

  ---- Dude… settings
  xmonad $ docks $ ewmh def
    { terminal           = "$${terminal}"
    , focusFollowsMouse  = $${focus_on_hover}
    , modMask            = $${modmask}
    , borderWidth        = 0                     --   No borders
    , workspaces         = myWorkspaces          --   Name my workspaces
    , logHook            = myLogHook d           --   Top(system) panel hook
    , manageHook         = myManageHook          --   Manage hook
    , layoutHook         = myLayoutHook          --   Layout algorithms
    , handleEventHook    = handleEventHook def <+> fullscreenEventHook
    , mouseBindings      = \x -> M.union (mouseBindings def x) (M.fromList myMouse)
    }`additionalKeys`                                -- Modifiy keybindings
    [ (( $${modmask}, xK_F4), kill)                  --   <Super>F4   ::  Kill window
    , (( $${modmask}, xK_F12), spawn "$${terminal}") --   <Super>F12  ::  Open terminal
$$>if test -n "${screenshooter}"; then
    , (( 0, xK_Print), spawn "$${screenshooter}")    --   SysReq      ::  Take a screen-shot
$$>fi
    , (( $${modmask}, xK_q), spawn myRestart)        --   modified restart command
    , (( $${modmask}, xK_F5), sendMessage $ JumpToLayout (decoName ++ "Tall"))
    , (( $${modmask}, xK_F6), sendMessage $ JumpToLayout (decoName ++ "Mirror Tall"))
    , (( $${modmask}, xK_F7), sendMessage $ JumpToLayout (decoName ++ "Grid"))
    , (( $${modmask}, xK_F8), sendMessage $ JumpToLayout "Full")
    {-- TODO , (( $${modmask} .|. controlMask, xK_m), withFocused (sendMessage . maximizeRestore)) --}
    {-- TODO , (( $${modmask}, xK_m), withFocused minimizeWindow) --}
    {-- TODO , (( $${modmask} .|. shiftMask , xK_m), sendMessage RestoreNextMinimizedWin) --}
    ]

{-- TODO preselect workspace 9 on secondary monitor --}


---- ==== Layout settings ==== ----
ratios = [ toRational (2/(1 + sqrt 5 :: Double)) -- golden ratio
         , toRational (sqrt 2 - 1 :: Double)     -- silver ratio
         , 1 / 2                                 -- half
         ]

$$>if ${with_decorations}; then
$$>    deco="imageButtonDeco shrinkText myTheme"
myTheme = (defaultThemeWithImageButtons
                {         activeColor = "#333333"
                ,       inactiveColor = "#000000"
                ,         urgentColor = "#880000"
                ,   activeBorderColor = "#888888"
                , inactiveBorderColor = "#888888"
                ,   urgentBorderColor = "#CD656C"
                ,     activeTextColor = "#EEEEEE"
                ,   inactiveTextColor = "#EEEEEE"
                ,     urgentTextColor = "#FFFFFF"
                , fontName            = "-misc-fixed-medium-r-normal-*-10-*-*-*-c-*-iso10646-1"
                , decoWidth           = 100
                , decoHeight          = 14
                , windowTitleAddons   = []
                {- , windowTitleIcons = [] -}
                })
{-- TODO decoName = "ImageButtonDeco Maximize Minimize " --}
decoName = "ImageButtonDeco Maximize "
$$>else
$$>    deco=
decoName = "Maximize Minimize "
$$>fi

myManageHook = manageDocks <+> manageHook def <+> composeAll
               [ className =? "XEyes"         --> doIgnore
               , className =? "TzClock"       --> doIgnore
               ]
myLayoutHook = avoidStruts $ myLayouts
myLayouts    = $${deco} (maximize {-- $ TODO minimize --} (tiled 2))
           ||| $${deco} (maximize {-- $ TODO minimize --} (Mirror (tiled 2)))
           ||| full
           ||| $${deco} (maximize {-- $ minimize --} Grid)
           ||| $${deco} (maximize {-- $ minimize --} (Mirror Grid))
           ||| full
tiled n      = Tall nmaster delta (ratios!!n)
full         = noBorders Full
nmaster      = 1
delta        = 1/100


---- ==== dzen2/xpybar (top panel) settings ==== ----
myLogHook h = do
  dynamicLogWithPP $ def
    { ppCurrent         = dzenColor "#303030" "#909090" . pad
    , ppHidden          = dzenColor "#909090" "" . pad
    , ppHiddenNoWindows = dzenColor "#606060" "" . pad
    , ppLayout          = dzenColor "#909090" "" . pad
    , ppUrgent          = dzenColor "#cd656c" "" . pad . dzenStrip
    , ppTitle           = shorten 100
    , ppWsSep           = ""
    , ppSep             = "  "
    , ppOutput          = hPutStrLn h
    }
  dynamicLogString def
    { ppSort = getSortByXineramaRule
    } >>= xmonadPropLog