summaryrefslogtreecommitdiffstats
path: root/xmonad.hs
blob: de41f6bd869bee43244f2eaa63f126320cdba769 (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
import XMonad
import XMonad.Config.Desktop
import XMonad.Hooks.EwmhDesktops

import System.Exit

import qualified Data.Map as M
import XMonad.Hooks.ManageHelpers
import qualified XMonad.StackSet as W

import XMonad.Hooks.DynamicLog
import XMonad.Util.Run
import XMonad.Util.SpawnOnce

import XMonad.Util.WorkspaceCompare

import XMonad.Hooks.ManageDocks
import XMonad.ManageHook
import XMonad.Util.NamedScratchpad

import XMonad.Layout.Grid
import XMonad.Layout.CenteredMaster
import XMonad.Layout.Circle
import XMonad.Layout.Grid
import XMonad.Layout.MosaicAlt
import XMonad.Layout.Tabbed
import XMonad.Layout.ResizableTile

import XMonad.Layout.SubLayouts
import XMonad.Layout.WindowNavigation
import XMonad.Layout.NoBorders

import XMonad.Layout.Named
import XMonad.Layout.Dwindle as DWIN
import XMonad.Layout.BinarySpacePartition as BSP

import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances

import XMonad.Layout.Spacing

import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.XMonad

import XMonad.Hooks.InsertPosition

-- xmobarEscape = concatMap doubleLts
--   where doubleLts '<' = "<<"
--         doubleLts x   = [x]

-- myWorkspaces :: [String]
-- myWorkspaces = clickable . (map xmobarEscape) $ ["1","2","3","4","5","6","7","8","9"]
--   where
--     clickable l = [ "<action=xdotool key Super_L+" ++ show (n) ++ ">" ++ ws ++ "</action>" |
--                     (i,ws) <- zip [1..9] l,
--                     let n = i ]

scratchpads = [
  NS "tmux" ("urxvt -name tmux -e tmux") (resource =? "tmux")
    (customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3))
  ]

main = do
  h <- spawnPipe "~/.cabal/bin/xmobar ~/.xmonad/xmobar.hs"
  xmonad $ ewmh $ docks def
    { terminal      = "urxvt-server-client"
    , modMask       = mod4Mask
    , startupHook   = startup
    , layoutHook    = myLayout
--    , workspaces    = ["1","2","3","4","5"]
--    , XMonad.workspaces    = myWorkspaces
--    , keys          = \c -> mykeys c `M.union` keys def c
    , keys          = mykeys
    , manageHook    = insertPosition Below Newer <+> myManageHook <+> manageDocks <+> namedScratchpadManageHook scratchpads <+> manageHook def
    , logHook       = dynamicLogWithPP . namedScratchpadFilterOutWorkspacePP $ myPP h
    }
  where
    mykeys (XConfig {modMask = modm}) =
      M.fromList $
      [ ((modm , xK_o), spawn "xlnch ~/xlnch/xlnchrc")
      , ((modm , xK_n), spawn "xlnch ~/xlnch/nude-xlnchrc")
      , ((modm , xK_p), spawn "passmenu")
      , ((modm , xK_j), spawn "jira-issue-nude.sh")
      , ((modm .|. controlMask, xK_x), shellPrompt def)
      , ((modm .|. shiftMask  , xK_x), xmonadPrompt def)
      , ((modm ,              xK_x), sendMessage MirrorShrink)
      , ((modm ,              xK_s), sendMessage MirrorExpand)
      , ((modm ,              xK_f), sendMessage $ Toggle NBFULL)
      , ((modm ,              xK_g), toggleWindowSpacingEnabled)
      -- , ((modm .|. shiftMask, xK_g), incWindowSpacing 2)
      -- , ((modm .|. controlMask, xK_g), decWindowSpacing 2)
      -- ; button
      , ((modm , 0x3B), namedScratchpadAction scratchpads "tmux")
      -- menu button
      -- , ((0    , 0xFF67), namedScratchpadAction scratchpads "tmux")
      , ((0    , 0x1008FF11), spawn "amixer -D pulse -q sset Master 2%-")
      , ((0    , 0x1008FF13), spawn "amixer -D pulse -q sset Master 2%+")
      , ((0    , 0x1008FF12), spawn "amixer set -D pulse Master toggle")

      , ((modm, xK_Return), spawn "urxvt-server-client")

        -- launch dmenu
      , ((modm,               xK_d     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
        -- launch gmrun
      , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
        -- close focused window
      , ((modm .|. shiftMask, xK_q     ), kill)
        -- Rotate through the available layout algorithms
      , ((modm,               xK_w ), sendMessage NextLayout)
      -- Reset the layouts on the current workspace to default
      --, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook def)
      -- Resize viewed windows to the correct size
      --, ((modm,               xK_n     ), refresh)
        -- Move focus to the next window
      , ((modm,               xK_Tab   ), windows W.focusDown)
        -- Move focus to the next window
      , ((modm,               xK_e     ), windows W.focusDown)
        -- Move focus to the previous window
      , ((modm,               xK_a     ), windows W.focusUp  )
        -- Move focus to the master window
      , ((modm,               xK_m     ), windows W.focusMaster  )
        -- Swap the focused window and the master window
      , ((modm .|. shiftMask, xK_Return), windows W.swapMaster)
        -- Swap the focused window with the next window
      , ((modm .|. shiftMask, xK_e     ), windows W.swapDown  )
        -- Swap the focused window with the previous window
      , ((modm .|. shiftMask, xK_a     ), windows W.swapUp    )
        -- Shrink the master area
      , ((modm,               xK_h     ), sendMessage Shrink)
        -- Expand the master area
      , ((modm,               xK_l     ), sendMessage Expand)
        -- Push window back into tiling
      , ((modm,               xK_t     ), withFocused $ windows . W.sink)
        -- Increment the number of windows in the master area
      , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
        -- Deincrement the number of windows in the master area
      , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
        -- toggle the status bar gap (used with avoidStruts from Hooks.ManageDocks)
        -- , ((modm , xK_b ), sendMessage ToggleStruts)
        -- Quit xmonad
      , ((modm .|. shiftMask, xK_z     ), io (exitWith ExitSuccess))
        -- Restart xmonad
      , ((modm              , xK_z     ), restart "xmonad" True) ]

      ++

      [ ((modm .|. controlMask, xK_h)      , sendMessage $ pullGroup L)
      , ((modm .|. controlMask, xK_l)      , sendMessage $ pullGroup R)
      , ((modm .|. controlMask, xK_k)      , sendMessage $ pullGroup U)
      , ((modm .|. controlMask, xK_j)      , sendMessage $ pullGroup D)
      , ((modm .|. controlMask, xK_m)      , withFocused (sendMessage . MergeAll))
      , ((modm .|. controlMask, xK_u)      , withFocused (sendMessage . UnMerge))
      , ((modm .|. controlMask, xK_period) , onGroup W.focusUp')
      , ((modm .|. controlMask, xK_comma)  , onGroup W.focusDown') ]

      ++

      --
      -- mod-[1..9], Switch to workspace N
      -- mod-shift-[1..9], Move client to workspace N
      --
      [((m .|. modm, k), windows $ f i)
      | (i, k) <- zip (XMonad.workspaces def) [xK_1 .. xK_9]
      , (f, m) <- [(W.view, 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 .|. modm, 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)]]

background = "feh --recursive --randomize --bg-scale ~/Pictures/wallpapers"

startup :: X ()
startup = do
  spawnOnce "xrandr --output Virtual1 --primary --mode 1440x900 --pos 0x0 --rotate normal --output Virtual2 --off --output Virtual3 --off --output Virtual4 --off --output Virtual5 --off --output Virtual6 --off --output Virtual7 --off --output Virtual8 --off"
  spawnOnce "trayer --edge top --align left --SetDockType true --SetPartialStrut true --expand true --transparent true --alpha 0 --tint 0x000000 --height 18 --width 5"
  spawnOnce "nm-applet"
  spawnOnce "dunst"
  spawnOnce "blueman-applet"
  --
  spawn background
  spawn "compton"
  spawn "xsetroot -cursor_name dot"
  spawn "setxkbmap -model pc104 -layout us,gr -variant qwerty -option grp:win_space_toggle,ctrl:nocaps,grp_led:scroll"

myLayout =
  mkToggle (NBFULL ?? EOT) $
  avoidStruts
  ( spacingRaw False (Border 10 10 10 10) False (Border 10 10 10 10) True $
    noBorders ( windowNavigation $ subTabbed $
                emptyBSP |||
                ResizableTall 1 (5/100) (1/2) [] |||
                -- MosaicAlt M.empty |||
                named "Dwindle" (Dwindle R DWIN.CW 1.5 1.1)
              )
    ||| noBorders Full
  )

myPP h1 = def { ppCurrent = xmobarColor "#1ABC9C" "" . wrap "[" "]"
                 , ppTitle   = xmobarColor "#1ABC9C" "" . shorten 60
                 , ppVisible = wrap "(" ")"
                 , ppUrgent  = xmobarColor "red" "yellow"
                 , ppSep     = " : "
                 , ppWsSep   = " "
                 , ppLayout  = (\x -> case x of
                                   "Spacing Tabbed Dwindle"       -> "@"
                                   "Spacing Tabbed ResizableTall" -> "|||"
                                   "Spacing Tabbed BSP"           -> "|\\|"
                                   "Spacing Tabbed MosaicAlt"     -> "|+|"
                                   "Spacing Full"                 -> "|=|"
                                   _                              -> x
                               )
                 , ppOutput  = hPutStrLn h1
           }

myManageHook = composeAll . concat $
   [ [ className =? "xlnch" --> doCenterFloat ] ]