-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmonad.hs
221 lines (197 loc) · 8.79 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
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
{-# LANGUAGE ImportQualifiedPost #-}
import Data.Map qualified as M
import Data.Word (Word32)
import Graphics.X11.ExtraTypes.XF86 qualified as XF86
import System.IO (hPutStrLn)
import XMonad
import XMonad.Actions.Minimize (withLastMinimized, minimizeWindow, maximizeWindow)
import XMonad.Hooks.DynamicLog (
ppHiddenNoWindows
, ppExtras
, ppTitle
, ppSep
, ppCurrent
, ppVisible
, ppUrgent
, ppOutput
, xmobarColor
, wrap
, dynamicLogWithPP
, xmobarPP
, shorten)
import XMonad.Hooks.EwmhDesktops (ewmh)
import XMonad.Hooks.ManageDocks (manageDocks, avoidStruts, docks)
import XMonad.Hooks.UrgencyHook (UrgencyHook(..), withUrgencyHook)
import XMonad.Layout.BoringWindows as BW
import XMonad.Layout.Fullscreen (fullscreenFull)
import XMonad.Layout.Minimize (minimize)
import XMonad.Layout.NoBorders (noBorders, smartBorders)
import XMonad.Layout.Spacing (spacingRaw, Border(..))
import XMonad.Layout.Tabbed (
activeColor
, activeBorderColor
, activeTextColor
, inactiveColor
, inactiveTextColor
, inactiveBorderColor
, tabbed
, shrinkText)
import XMonad.StackSet qualified as W
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Util.NamedWindows (getName)
import XMonad.Util.Run (safeSpawn, spawnPipe)
import XMonad.Util.SpawnOnce (spawnOnce)
-- import XMonad.Actions.SpawnOn
-- import XMonad.Hooks.ManageHelpers
-- import XMonad.Hooks.SetWMName
-- import XMonad.Layout
-- import XMonad.Layout.Maximize
-- import XMonad.Layout.PerWorkspace
-- import XMonad.Layout.ResizableTile
-- import XMonad.Layout.Spiral
-- import XMonad.Layout.ThreeColumns
-- import XMonad.Layout.WorkspaceDir
-- import XMonad.Util.Font
-- import XMonad.Util.Loggers
-- import XMonad.Wallpaper
-- Border Styling
myBorderWidth :: Word32
myBorderWidth = 3
myNormalBorderColor :: String
myNormalBorderColor = "#BFBFBF"
myFocusedBorderColor :: String
myFocusedBorderColor = "#89DDFF"
myWorkspaces :: [String]
myWorkspaces = ["一", "二", "三", "四", "五", "六", "七", "八", "九"]
where
clickable l =
[ "<action=xdotool key mod4Mask+" ++ show n ++ ">" ++ ws ++ "</action>"
| (i, ws) <- zip [1 .. 9] l
, let n = i
]
data LibNotifyUrgencyHook = LibNotifyUrgencyHook deriving (Read, Show)
instance UrgencyHook LibNotifyUrgencyHook where
urgencyHook LibNotifyUrgencyHook w = do
name <- getName w
Just idx <- W.findTag w <$> gets windowset
safeSpawn "notify-send" [show name, "workspace" ++ idx]
-- xmobarEscape = concatMap doubleLts
-- where doubleLts '<' = "<<"
-- doubleLts x = [x]
--
-- myWorkspaces :: [String]
-- myWorkspaces = clickable . (map xmobarEscape) $ ["一","二","三","四","五","六","七","八","九"]
-- where clickable l = ["<action=xdotool key alt+" ++ show (n) ++ ">" ++ ws ++ "</action>" |
-- (i,ws) <- zip [1..9] l,
-- let n = i ]
myTerminal :: String
myTerminal = "alacritty"
gaps = spacingRaw True (Border 0 0 0 0) False (Border 8 8 8 8) True -- gaps (border / window spacing)
-- myLayout = maximize (ResizableTall 1 (3 / 100) (1 / 2) [] ||| Full)
myLayout =
avoidStruts
( -- ThreeColMid 1 (3/100) (1/2) |||
Tall 1 (3 / 100) (1 / 2)
||| Mirror (Tall 1 (3 / 100) (1 / 2))
||| tabbed shrinkText tabConfig
||| Full
)
|||
-- Full) |||
-- spiral (6/7)) |||
noBorders (fullscreenFull Full)
tabConfig =
def
{ activeBorderColor = "#7C7C7C"
, activeTextColor = "#CEFFAC"
, activeColor = "#000000"
, inactiveBorderColor = "#7C7C7C"
, inactiveTextColor = "#EEEEEE"
, inactiveColor = "#000000"
}
myXmobarrc :: String
myXmobarrc = "xmobar $HOME/.config/xmobar/xmobarrc.hs"
xmobarTitleColor = "#FFB6B0"
-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "#CEFFAC"
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
localBin :: String -> String
localBin x = "$HOME/.local/bin/" <> x
main :: IO ()
main = do
--setRandomWallpaper ["$HOME/Pictures/nixos-onedark-wallpaper.png"]
xmproc <- spawnPipe myXmobarrc
xmonad $
docks $
withUrgencyHook LibNotifyUrgencyHook $
ewmh $
def
{ manageHook = manageDocks <+> manageHook def -- replaced defaultConfig by def
, layoutHook = myLayoutHook
, logHook =
dynamicLogWithPP
xmobarPP
{ ppOutput = hPutStrLn xmproc
, -- , ppTitle = xmobarColor "#98c379" "" . shorten 100
ppTitle = xmobarColor "#d0d0d0" "" . shorten 80 -- Title of active window in xmobar
-- , ppCurrent = xmobarColor "#61afef" "" . wrap "[" "]"
, ppCurrent = xmobarColor "#6495ED" "" . wrap "[" "]"
, ppUrgent = xmobarColor "red" "yellow"
, ppVisible = wrap "(" ")"
, ppSep = "<fc=#9AEDFE> :: </fc>" -- Separators in xmobar
, ppExtras = [windowCount] -- # of windows current workspace
, ppHiddenNoWindows = xmobarColor "#F07178" ""
}
, borderWidth = myBorderWidth
, -- , startupHook = ewmhDesktopsStartup >> setWMName "LG3D"
-- , startupHook = myStartupHooker >> setWMName "LG3D"
startupHook = myStartupHook
, modMask = mod4Mask
, workspaces = myWorkspaces
, terminal = myTerminal
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
}
`additionalKeys` myKeys
myLayoutHook = minimize . BW.boringWindows $ avoidStruts $ gaps $ smartBorders myLayout
myKeys =
[ -- myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ [
-- ((mod4Mask, xK_p ), spawn "j4-dmenu-desktop --dmenu=\"dmenu_run -fn 'monospace:regular:pixelsize=12' -nb '#282c34' -sf '#282c34' -sb '#98c379' -nf '#abb2bf'\"" ) ,
-- ((mod4Mask, xK_p), spawn "dmenu_run -i -p 'Packages' -fn 'Fira Mono:bold:pixelsize=15' -nb '#5b247a' -nf '#ce9ffc' -sf '#3425AF' -sb '#ce9ffc'")
((mod4Mask, xK_p), spawn "rofi -show run")
, ((mod4Mask, xK_i), spawn "kill -s USR1 $(pidof deadd-notification-center)")
, ((mod4Mask .|. controlMask, xK_i), (spawn . localBin) "dunicode")
, ((mod4Mask .|. shiftMask, xK_i), (spawn . localBin) "dunicode 1")
, ((mod4Mask .|. shiftMask, xK_e), spawn "nemo")
, ((mod4Mask .|. shiftMask, xK_n), spawn "joplin-desktop")
, ((mod4Mask .|. shiftMask, xK_t), spawn "nixGL telegram-desktop")
, ((mod4Mask .|. shiftMask, xK_w), spawn "chromium")
, ((mod4Mask .|. shiftMask, xK_b), spawn "brave")
, ((mod4Mask .|. shiftMask, xK_s), spawn "maim -s | xclip -selection clipboard -t image/png")
, ((mod4Mask .|. shiftMask, xK_d), spawn "discord")
, ((mod4Mask .|. controlMask, xK_k), spawn "kitty")
, ((mod1Mask .|. controlMask, xK_l), spawn "i3lock-fancy")
, ((mod1Mask, xK_m), withFocused minimizeWindow)
, ((mod1Mask .|. shiftMask, xK_m), withLastMinimized maximizeWindow)
, ((0, XF86.xF86XK_AudioMute), spawn "amixer set Master toggle")
, ((0, XF86.xF86XK_AudioLowerVolume), spawn "amixer -q set Master 5%-")
, ((0, XF86.xF86XK_AudioRaiseVolume), spawn "amixer -q sset Master 5%+")
, ((0, XF86.xF86XK_MonBrightnessDown), spawn "xbacklight -dec 5")
, ((0, XF86.xF86XK_MonBrightnessUp), spawn "xbacklight -inc 5")
]
myStartupHook = do
-- spawnOnce "xbacklight -set 30"
spawnOnce "xrandr --output DP-2 --brightness 0.7"
spawnOnce "mpd"
spawnOnce "mpd-notification"
spawnOnce "ibus-daemon -drxR"
spawnOnce "compton --config ~/.compton.conf"
spawnOnce "unclutter"
-- spawnOnce "trayer --expand true --transparent true --alpha 255 --edge bottom --align right --expand true --SetDockType true --widthtype request"
spawnOnce "trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 2 --transparent true --alpha 0 --tint 0x292d3e --height 22"
-- spawnOnce "xmodmap ~/.Xmodmap"
spawnOnce "setxkbmap -option caps:swapescape -option compose:ralt"
spawnOnce "nitrogen --restore &"
spawnOnce "clipit"
-- spawnHere "xloadimage -onroot -fullscreen ~/Pictures/nixos-onedark-wallpaper.png"
-- spawnOn "workspace2" "pulseeffects"