summaryrefslogtreecommitdiffstats
path: root/xmonad.hs
blob: 560a77b7d6756be93fe4233b1bc49c3d4c25cca0 (plain)
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
import XMonad
import XMonad.Config.Desktop
import XMonad.Config.Gnome
import XMonad.Actions.CycleWS
import XMonad.Actions.NoBorders
import XMonad.Actions.PhysicalScreens
import XMonad.Actions.Warp
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Layout.ResizableTile
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig

import Control.Monad
import Control.Monad.Trans
import Data.Maybe
import Data.Monoid
import Ratio((%))

--import ConfigurableBorders
import FullscreenManager
import NoBorders
import ProcessWorkspaces


modm = mod4Mask

main = xmonad $ gnomeConfig
       { modMask = modm
       , manageHook = myManageHook
       , layoutHook = desktopLayoutModifiers myLayoutHook
       , startupHook = myStartupHook
       , handleEventHook = myEventHook
       }
       `additionalKeysP`
       [ ("M-a", sendMessage MirrorShrink)
       , ("M-y", sendMessage MirrorExpand)
       , ("M-<Left>",    prevWS)
       , ("M-<Right>",   nextWS)
       , ("M-S-<Left>",  shiftToPrev)
       , ("M-S-<Right>", shiftToNext)
       , ("M-S-b", withFocused toggleBorder >> refresh)
       , ("M1-<F4>", kill)
       , ("M-<F1>", viewOrWarp 0)
       , ("M-<F2>", viewOrWarp 1)
       , ("M-<F3>", viewOrWarp 2)
       , ("M-p", spawnOnCurrent "exe=`dmenu_path | /home/neoraider/bin/dmemu -b` && eval \"exec $exe\"")
       ]
       `additionalMouseBindings`
       [ ((modm, button4), \_ -> sendMessage Shrink)
       , ((modm, button5), \_ -> sendMessage Expand)
       , ((modm .|. shiftMask, button4), \_ -> sendMessage MirrorExpand)
       , ((modm .|. shiftMask, button5), \_ -> sendMessage MirrorShrink)
       ]


viewOrWarp :: Int -> X ()
viewOrWarp n = do
  wset <- gets windowset
  i <- getScreen $ P n
  whenJust i $ \s -> do
                 ws <- screenWorkspace s
                 whenJust ws $ \w -> windows . W.view $ w
                 when (s == (W.screen . W.current $ wset)) $ warpToScreen s (1%2) (1%2)


--myStartupHook :: X ()
--myStartupHook = do
--  startupHook gnomeConfig
--  spawn "killall -u `id -un` -q xcompmgr; exec xcompmgr"

myStartupHook :: X ()
myStartupHook = do
  startupHook gnomeConfig
  setWMName "LG3D"


myManageHook :: ManageHook
myManageHook = composeAll
               [ composeOne
                 [ isDialog                  -?> doFloat
                 , className =? "Guake.py"   -?> doFloatMaybeFullscreen -- <+> doConfigBorderOff)
                   --, className =? "Do"         -?> (doFloat <+> doConfigBorderOff)
                 , className =? "MPlayer"    -?> doCenterFloat
                 , className =? "Gimp"       -?> doFloat
                 , className =? "Display"    -?> doFloat
                 , className =? "Wine"       -?> doFloat
                 , className =? "Pcsx2"      -?> doFloat
                 , stringProperty "WM_ICON_NAME" =? "ZeroGS" -?> doFloat
                 , isFullscreen              -?> doFullscreen
                 ]
               , moveWindowHook
               , manageHook gnomeConfig
               ]
        

myLayoutHook = processWorkspaceStorage $ manageFullscreen $ smartBorders (Full ||| tiled ||| Mirror tiled)
  where
    -- default tiling algorithm partitions the screen into two panes
    tiled   = ResizableTall nmaster delta ratio []
 
    -- The default number of windows in the master pane
    nmaster = 1
 
    -- Default proportion of screen occupied by master pane
    ratio   = 3/5 

    -- Percent of screen to increment by when resizing panes
    delta   = 3/100

myEventHook :: Event -> X All
myEventHook ev = do
  handleFullscreen ev
  (handleEventHook gnomeConfig) ev