summaryrefslogtreecommitdiff
path: root/xmonad.hs
blob: 143f4a292b45eb5cf5b9c764e1c88471e23f219b (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 System.Exit
import XMonad
import XMonad.Actions.CycleWS
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Layout.IndependentScreens
import XMonad.Layout.Renamed
import XMonad.Layout.Spacing
import XMonad.Prompt
import XMonad.Prompt.FuzzyMatch
import XMonad.Prompt.Pass
import qualified XMonad.StackSet as W
import XMonad.Util.Cursor
import XMonad.Util.EZConfig
import XMonad.Util.SpawnOnce

primary = "#a1b56c"
grey0 = "#181818"
grey1 = "#585858"
grey2 = "#b8b8b8"
grey3 = "#f8f8f8"

main :: IO ()
main = do
    nScreens <- countScreens
    xmonad
        . ewmhFullscreen
        . ewmh
        . withEasySB
            ( statusBarProp
                "xmobar"
                ( pure
                    ( marshallPP
                        (S 0)
                        def
                            { ppSep = ""
                            , ppWsSep = ""
                            , ppHiddenNoWindows = xmobarColor grey2 grey0 . pad
                            , ppCurrent = xmobarColor grey3 primary . pad
                            , ppHidden = xmobarBorder "Top" primary 2 . xmobarColor grey2 grey0 . pad
                            , ppTitle = const ""
                            , ppLayout = xmobarColor grey2 grey0 . pad
                            }
                    )
                )
            )
            defToggleStrutsKey
        $ let promptConfig =
                def
                    { position = Top
                    , bgColor = grey0
                    , bgHLight = primary
                    , promptBorderWidth = 0
                    , fgHLight = grey3
                    , height = 25
                    , font = "xft:Hermit:size=12"
                    , searchPredicate = fuzzyMatch
                    , sorter = fuzzySort
                    , alwaysHighlight = True
                    }
           in def
                { borderWidth = 2
                , workspaces = [marshall s vw | vw <- (map show [1 .. 9]), s <- [0 .. nScreens]]
                , layoutHook =
                    renamed
                        [Replace "[]="]
                        (spacingWithEdge 8 $ Tall 1 (5 / 100) (1 / 3))
                        ||| renamed [Replace "[M]"] Full
                , normalBorderColor = grey1
                , focusedBorderColor = primary
                , keys = \c ->
                    mkKeymap c $
                        [ ("M-<Return>", spawn "alacritty")
                        , ("M-q", kill)
                        , ("M-d", spawn $ "bemenu-run -p ' ' --cw 2")
                        , ("M-r", spawn "xmonad --recompile && xmonad --restart")
                        , ("M-w", spawn "slock")
                        , ("M-S-e", io exitSuccess)
                        , ("M-j", windows W.focusDown)
                        , ("M-k", windows W.focusUp)
                        , ("M-c", passPrompt promptConfig)
                        , ("M-x", passOTPPrompt promptConfig)
                        , ("M-i", sendMessage $ IncMasterN 1)
                        , ("M-u", sendMessage $ IncMasterN $ -1)
                        , ("M-h", sendMessage Shrink)
                        , ("M-l", sendMessage Expand)
                        , ("M-m", sendMessage $ JumpToLayout "[M]")
                        , ("M-t", sendMessage $ JumpToLayout "[]=")
                        ,
                            ( "M-<Tab>"
                            , gets (W.screen . W.current . windowset)
                                >>= \currentScreen ->
                                    toggleWS'
                                        [ marshall s vw
                                        | vw <- (map show [1 .. 9])
                                        , s <- [x | x <- [0 .. nScreens], x /= currentScreen]
                                        ]
                            )
                        , ("M-S-<Return>", windows W.swapMaster)
                        , ("M-S-<Space>", withFocused $ windows . W.sink)
                        ]
                            ++ concatMap
                                ( \n ->
                                    [ ("M-" ++ n, windows $ onCurrentScreen W.greedyView n)
                                    , ("M-S-" ++ n, windows $ onCurrentScreen W.shift n)
                                    ]
                                )
                                (map show [1 .. 9])
                , startupHook =
                    do
                        spawnOnce "feh --bg-fill --no-fehbg --randomize /home/tom/src/nixos/wallpapers"
                        spawnOnce "xautolock -locker slock -time 1"
                        setDefaultCursor xC_left_ptr
                }