-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathxmonad.hs
209 lines (180 loc) · 6.64 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
--
-- ~/.xmonad/xmonad.hs
--
import System.Posix.Env (getEnv)
import System.IO
import System.Directory
import Data.Maybe (maybe)
import Graphics.X11.ExtraTypes.XF86
import XMonad
import XMonad.Config.Desktop
import XMonad.Config.Gnome
import XMonad.Config.Kde
import XMonad.Config.Xfce
import XMonad.Layout.Grid
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
import XMonad.Layout.ThreeColumns
import XMonad.Actions.PhysicalScreens
import XMonad.Actions.CycleWS
import qualified XMonad.Actions.DynamicWorkspaceOrder as DO
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.SetWMName
import XMonad.Util.EZConfig
import XMonad.Util.NamedScratchpad
import XMonad.Util.Run (spawnPipe)
import XMonad.Util.Ungrab
import XMonad.Util.WorkspaceCompare
import qualified XMonad.StackSet as W
--
-- basic configuration
--
myModMask = mod4Mask -- use the Windows key as mod
myBorderWidth = 2 -- set window border size
myTerminal = "urxvt256c-ml" -- preferred terminal emulator
--
-- key bindings
--
myKeys = [
((myModMask, xK_a), sendMessage MirrorShrink) -- for ResizableTall
, ((myModMask, xK_z), sendMessage MirrorExpand) -- for ResizableTall
-- selecting particular monitors
, ((myModMask, xK_w), viewScreen def 0)
, ((myModMask, xK_e), viewScreen def 1)
, ((myModMask, xK_r), viewScreen def 2)
-- cycling through workspaces in multi monitor setup, skipping scratchpad
, ((myModMask .|. mod5Mask, xK_h), prevHiddenNonEmptyNoSPWS)
, ((myModMask, xK_Left), prevHiddenNonEmptyNoSPWS)
, ((myModMask .|. mod5Mask, xK_l), nextHiddenNonEmptyNoSPWS)
, ((myModMask, xK_Right), nextHiddenNonEmptyNoSPWS)
, ((myModMask, xK_o), namedScratchpadAction scratchpads "pad")
, ((myModMask, xK_v), namedScratchpadAction scratchpads "vol")
, ((myModMask, xK_d), namedScratchpadAction scratchpads "timelog")
, ((myModMask, xK_e), namedScratchpadAction scratchpads "padedit")
, ((myModMask, xK_s), spawn "/usr/bin/mpc toggle")
, ((0, xK_Print), unGrab >> spawn "flameshot-gui-hack")
--((myModMask, xK_d), spawn "/home/martin/bin/qstardict-show-hide.sh")
]
where
getSortByIndexNoSP = fmap (. filterOutWs [scratchpadWorkspaceTag]) getSortByIndex
prevHiddenNonEmptyNoSPWS = windows . W.greedyView =<< findWorkspace getSortByIndexNoSP Prev (hiddenWS :&: Not emptyWS) 1
nextHiddenNonEmptyNoSPWS = windows . W.greedyView =<< findWorkspace getSortByIndexNoSP Next (hiddenWS :&: Not emptyWS) 1
-- key bindings used only in stand alone mode (without KDE)
myStandAloneKeys = [
((myModMask, xK_x), spawn "xscreensaver-command -lock")
, ((0, xF86XK_MonBrightnessUp), spawn "brightnessctl set +5%")
, ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 5%-")
, ((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pipewire sset Master 10%+")
, ((0, xF86XK_AudioLowerVolume), spawn "amixer -D pipewire sset Master 10%-")
, ((0, xF86XK_AudioMute), spawn "amixer -D pipewire sset Master toggle")
, ((0, xF86XK_AudioMicMute), spawn "amixer -D pipewire sset Capture toggle")
]
--
-- yakuake like named scratchpads
--
scratchpads :: [NamedScratchpad]
scratchpads = [
NS "pad" (myTerminal ++ " -name pad -e bash -c '/usr/bin/tmuxp load pad -y'") (resource =? "pad") (customFloating $ (W.RationalRect l t w h))
, NS "vol" "pavucontrol" (className =? "pavucontrol") (customFloating $ W.RationalRect (1/4) (1/4) (2/4) (2/4))
, NS "timelog" "gtimelog" (className =? "Gtimelog") (customFloating $ W.RationalRect 0.375 0 (1/4) 0.4)
, NS "padedit" "kwrite ~/tmp/pad" (className =? "kwrite") (customFloating $ W.RationalRect (1/4) (1/4) (2/4) (2/4))
]
where
h = 0.4 -- terminal height, 40%
w = 1 -- terminal width, 100%
t = 1 - h -- distance from top edge, 90%
l = 1 - w -- distance from left edge, 0%
--
-- hooks for newly created windows
-- note: run 'xprop WM_CLASS' to get className
--
myManageHook :: ManageHook
myManageHook = manageDocks <+> (namedScratchpadManageHook scratchpads) <+> coreManageHook
coreManageHook :: ManageHook
coreManageHook = composeAll . concat $
[ [ className =? c --> doFloat | c <- myFloats]
, [ appName =? c --> doFloat | c <- myFloatApps]
, [ className =? c --> doF (W.shift "1") | c <- mailIrcApps]
]
where
myFloats = [
"MPlayer"
, "Gimp"
, "Plasma-desktop"
, "plasmashell"
, "krunner"
, "Klipper"
, "Keepassx"
, "Starplot"
, "spectacle"
, "virt-manager"
]
myFloatApps = [
"Alert"
]
mailIrcApps = [
"org.mozilla.thunderbird"
, "konversation"
, "Mail"
]
--
-- startup hooks
--
myStartupHook = setWMName "LG3D"
--
-- layout hooks
--
myLayoutHook = smartBorders $ avoidStruts $ coreLayoutHook
coreLayoutHook = tiled ||| Mirror tiled ||| Full ||| tiled3 ||| Grid
where
-- default tiling algorithm partitions the screen into two panes
tiled = ResizableTall nmaster delta ratio []
-- like the tall, but with three columns
tiled3 = ThreeColMid nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Percent of screen to increment by when resizing panes
delta = 3/100
-- Default proportion of screen occupied by master pane
ratio = 1/2
--
-- log hook (for xmobar)
--
myLogHook xmproc = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
--
-- desktop :: DESKTOP_SESSION -> desktop_configuration
--
desktop "gnome" = gnomeConfig
desktop "xmonad-gnome" = gnomeConfig
desktop "kde" = kde4Config
desktop "kde-plasma" = kde4Config
desktop "plasma" = kde4Config
desktop "xfce" = xfceConfig
desktop _ = desktopConfig
--
-- main function (no configuration stored there)
--
main :: IO ()
main = do
session <- getEnv "DESKTOP_SESSION"
let defDesktopConfig = maybe desktopConfig desktop session
myDesktopConfig = defDesktopConfig
{ modMask = myModMask
, borderWidth = myBorderWidth
, startupHook = myStartupHook
, layoutHook = myLayoutHook
, manageHook = myManageHook <+> manageHook defDesktopConfig
} `additionalKeys` myKeys
-- when running standalone (no KDE), try to spawn xmobar (if installed)
xmobarInstalled <- doesFileExist "/usr/bin/xmobar"
if session == Just "xmonad" && xmobarInstalled
then do mproc <- spawnPipe "/usr/bin/xmobar ~/.xmonad/xmobar.hs"
xmonad $ myDesktopConfig
{ logHook = myLogHook mproc
, terminal = myTerminal
} `additionalKeys` myStandAloneKeys
else do xmonad myDesktopConfig