-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmonad.hs
183 lines (158 loc) · 6.19 KB
/
xmonad.hs
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
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops ( ewmh
, fullscreenEventHook
)
import XMonad.Hooks.ManageHelpers ( doCenterFloat
, doFullFloat
, isFullscreen
)
import XMonad.ManageHook
import XMonad.Util.EZConfig
import XMonad.Util.NamedScratchpad
import XMonad.Util.SpawnOnce
import XMonad.Layout.CenteredMaster
import XMonad.Layout.NoBorders ( noBorders
, smartBorders
)
import XMonad.Layout.Renamed ( Rename(Replace)
, renamed
)
import XMonad.Layout.Spacing
import XMonad.Layout.ToggleLayouts as T
import qualified XMonad.StackSet as W
import GHC.IO.Exception ( ExitCode(ExitSuccess) )
import System.Exit ( exitSuccess )
myTerminal = "alacritty"
myBar = "xmobar ~/.xmonad/.xmobarrc"
myTray = "trayer"
myBacklitCtl = "brightnessctl"
myTrayOptions =
"--edge bottom --align right --SetDockType true --SetPartialStrut true \
\--expand true --transparent true --alpha 0 \
\--tint "
++ "0x"
++ tail myNormalBorderColor -- trayer bg color
++ " &"
myBrowser = "brave"
myAppLauncher =
"rofi -theme gruvbox-dark-hard -lines 12 -padding 18 -width 60 -location 0 -show drun -sidebar-mode -columns 3 -font 'Hasklug Nerd Font 12'"
myMenu =
"dmenu_run -nf '#fbf1c7' -sf '"
++ myNormalBorderColor
++ "' -sb '"
++ myFocusedBorderColor
++ "' -fn 'Hasklug Nerd Font:size=10'"
myModMask = mod4Mask -- Win key or Super_L
myBorderWidth = 4
myNormalBorderColor = "#282828"
myFocusedBorderColor = "#98971a"
-- Scratchpads
scratchpads :: [NamedScratchpad]
scratchpads = [pad "htop", pad "pulsemixer", pad "ranger"]
where
command pad = myTerminal ++ " --class '" ++ pad ++ "' -e " ++ pad
pad name = NS name (command name) (resource =? name) defaultFloating
-- Custom PP, configure it as you like. It determines what is being written to the bar.
myPP :: PP
myPP =
xmobarPP { ppCurrent = xmobarColor myFocusedBorderColor "" . wrap "[" "]" }
myManageHook =
composeAll
[ appName =? "pulsemixer" --> doCenterFloat
, appName =? "htop" --> doCenterFloat
, appName =? "ranger" --> doCenterFloat
, isFullscreen --> doFullFloat
]
<+> namedScratchpadManageHook scratchpads
-- Keybinds
myKeys =
-- App shortcuts
[ ("M-b" , spawn myBrowser)
, ("M1-b", spawn $ myBrowser ++ " --incognito")
, ("M1-s" , spawn "slack")
, ("M1-e" , spawn "element-desktop")
, ("M-<Return>" , spawn myTerminal)
, ("<Print>" , spawn "flameshot gui")
-- Layout and Window controls
, ("M1-<Return>", windows W.swapMaster)
, ("M-f" , sendMessage T.ToggleLayout)
, ("M-q" , kill)
-- Scratchpads
, ("M-S-e", namedScratchpadAction scratchpads "ranger")
, ("M-S-t", namedScratchpadAction scratchpads "htop")
, ("M-S-p", namedScratchpadAction scratchpads "pulsemixer")
-- Runner shortcuts
, ("M1-p" , spawn myAppLauncher)
, ("M-p" , spawn myMenu)
-- Restart xmonad
, ( "M-r"
, spawn
"if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi"
)
-- Audio Controls
, ("<XF86AudioMute>", spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle")
, ( "<XF86AudioLowerVolume>"
, spawn "pactl set-sink-volume @DEFAULT_SINK@ -10%"
)
, ( "<XF86AudioRaiseVolume>"
, spawn "pactl set-sink-volume @DEFAULT_SINK@ +10%"
)
-- Brightness controls
, ("<F1>", spawn $ myBacklitCtl ++ " s 1%")
, ("<F2>", spawn $ myBacklitCtl ++ " s 10%-")
, ("<F3>", spawn $ myBacklitCtl ++ " s 10%+")
-- MSI keyboard backlit control
, ("<F4>", spawn "~/.config/mybin/dm_msi_opt")
]
-- Autostarts startup :: X ()
myStartup = do
spawn ("killall " ++ myTray)
spawn ("sleep 2 && " ++ myTray ++ " " ++ myTrayOptions)
spawnOnce "pasystray"
spawnOnce "nm-applet"
spawnOnce "pamac-tray"
spawnOnce "xfce4-power-manager"
spawnOnce "picom --experimental-backends --corner-radius 8 -o 0.0 -b"
spawnOnce "~/.fehbg"
-- Key binding to toggle the gap for the bar.
toggleStrutsKey XConfig { XMonad.modMask = modMask } = (mod1Mask, xK_f)
-- Layout
myLayout = toggledTiled ||| toggledMirror ||| toggledCentered
where
-- default tiling algorithm partitions the screen into two panes
tiled = alias "Tall" $ smartSpacingWithEdge 4 $ smartBorders $ Tall nmaster
delta
ratio
full = noBorders Full
mirror = alias "Mirrored" $ Mirror tiled
-- Tiled layouts with toggles for Full mode
toggledTiled = T.toggleLayouts full tiled
toggledMirror = T.toggleLayouts full mirror
-- Centered master layout with toggle for centered or top-right masters
toggledCentered = alias "Centered"
$ T.toggleLayouts (topRightMaster tiled) (centerMaster tiled)
-- Function to rename layouts
alias a = renamed [Replace a]
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 2 / 3
-- Percent of screen to increment by when resizing panes
delta = 3 / 100
-- Main configuration
myConfig =
def { terminal = myTerminal
, modMask = myModMask
, borderWidth = myBorderWidth
, manageHook = myManageHook
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
, handleEventHook = fullscreenEventHook
, startupHook = myStartup
, layoutHook = myLayout
}
`additionalKeysP` myKeys
main :: IO ()
main = do
xmonad . ewmh =<< statusBar myBar myPP toggleStrutsKey myConfig