-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmonad.hs
219 lines (208 loc) · 9.87 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
import XMonad
import XMonad.Layout.Spacing
import XMonad.Layout.PerWorkspace
import XMonad.Layout.IM
import XMonad.Layout.Grid
import XMonad.Layout.NoBorders
import XMonad.Layout.Simplest
import XMonad.Layout.Fullscreen
import XMonad.Layout.Roledex
import XMonad.Layout.Reflect
import XMonad.Layout.TrackFloating
import XMonad.Layout.ComboP
import XMonad.Layout.TwoPane
import Data.Ratio ((%))
import qualified Data.Map as M
import Graphics.X11.ExtraTypes.XF86
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Util.Run
import XMonad.Actions.SpawnOn
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.Tabbed
import qualified XMonad.StackSet as W
import XMonad.Actions.CycleWS
import XMonad.Actions.CycleRecentWS
import XMonad.Hooks.ManageHelpers
import System.IO
import XMonad.Util.SpawnOnce
import XMonad.Actions.GridSelect
-- to get info on the windows with wmctrl
import XMonad.Hooks.EwmhDesktops
import qualified XMonad.StackSet as W
-- Nice idea:
-- https://pbrisbin.com/posts/using_notify_osd_for_xmonad_notifications/
-- But this requires to configure the terminal and I don't want notifications
-- for everything, just long running background processes. If there was a way
-- to set this automatically, that would be rad.
--
-- import XMonad.Util.NamedWindows
-- import XMonad.Util.Run
-- import XMonad.Hooks.UrgencyHook
-- withUrgencyHook LibNotifyUrgencyHook
-- data LibNotifyUrgencyHook = LibNotifyUrgencyHook deriving (Read, Show)
--
-- instance UrgencyHook LibNotifyUrgencyHook where
-- urgencyHook LibNotifyUrgencyHook w = do
-- name <- getName w
-- Just idx <- fmap (W.findTag w) $ gets windowset
--
-- safeSpawn "notify-send" [show name, "workspace " ++ idx]
-- HINTs
-- * use xprop to figure out window name
-- * restart with MOD-Q
myWorkspaces = ["1","2","3","4","5","6","7","8","9","a:✉","s:☏","d:☺","f:⌂"]
myManageHook = composeAll
[
isDialog --> doFloat
, className =? "Pidgin" --> doShift "d:☺"
, className =? "chromium" --> doShift "s:☏"
, className =? "Chromium" --> doShift "s:☏"
, className =? "Thunderbird" --> doShift "a:✉"
, className =? "Gnome-logs" --> doShift "f:⌂"
, className =? "Keepassx" --> doShift "f:⌂"
, className =? "Wine" --> doFullFloat
, className =? "sun-awt-X11-XDialogPeer" --> doFullFloat
, className =? "jetbrains-idea-ce" <&&> appName =? "sun-awt-X11-XWindowPeer" --> doIgnore
--and wmName =? contains win343
--[ appName =? "sun-awt-X11-XWindowPeer" <&&> className =?
--"jetbrains-idea" --> doIgnore ]
, className =? "Vlc" --> doFullFloat
, role =? "AlarmWindow" --> doRectFloat(W.RationalRect 0.25 0.25 0.3 0.2)
, className =? "Arandr" --> doCenterFloat
, className =? "Pavucontrol" --> doRectFloat(W.RationalRect 0.25 0.25 0.5 0.5)
, className =? "Pavucontrol" --> doRectFloat(W.RationalRect 0.25 0.25 0.5 0.5)
, className =? "Blueman-manager" --> doRectFloat(W.RationalRect 0.25 0.25 0.5 0.5)
]
where role = stringProperty "WM_WINDOW_ROLE"
keysToAdd x = [
--,((mod4Mask, xK_Return), spawn "terminator")
((0, xF86XK_AudioMute), spawn "amixer -D pulse sset Master toggle")
,((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 5%+")
,((0, xF86XK_AudioLowerVolume), spawn "amixer -D pulse sset Master 5%-")
--,((0, xF86XK_Display), spawn "scrot '/home/thoth/view/screen_capture/%Y_%m_%d_%H:%M:%S.png'")
--,((0, xF86XK_AudioMicMute), spawn "amixer -c 0 -q set Master 2dB-")
,((0, xF86XK_MonBrightnessDown), spawn "xbacklight -dec 5")
,((0, xF86XK_MonBrightnessUp), spawn "xbacklight -inc 5")
--,((0, xF86XK_Display), spawn "amixer -c 0 -q set Master 2dB-")
--,((0, xF86XK_WLAN), spawn "amixer -c 0 -q set Master 2dB-")
--,((0, xF86XK_Tools), spawn "amixer -c 0 -q set Master 2dB-")
,((0, xF86XK_LaunchA), spawn "i3lock -f -c 000000")
,((0, xF86XK_Explorer), spawn "systemctl suspend")
,((mod4Mask, xK_F12), spawn "systemctl suspend")
,((mod4Mask, xK_F11), spawn "i3lock -f -c 000000")
,((mod4Mask, xK_KP_Begin), goToSelected defaultGSConfig)
,((mod4Mask, xK_KP_Down), spawnSelected defaultGSConfig ["eaglemode","calibre","vlc", "skype", "starcraft"])
,((mod4Mask, xK_BackSpace), spawn "xterm ranger")
--,((0, xF86XK_Tools), spawn "/usr/bin/togglexkbmap")
,((0, xF86XK_Tools), spawn "xmodmap ~/.Xmodmap")
--,((0, xF86XK_MyComputer), spawn "amixer -c 0 -q set Master 2dB-")
,((mod4Mask, xK_a), (windows $ W.view "a:✉"))
,(((mod4Mask .|. shiftMask), xK_a), (windows $ W.shift "a:✉"))
,((mod4Mask, xK_s), (windows $ W.view "s:☏"))
,(((mod4Mask .|. shiftMask), xK_s), (windows $ W.shift "s:☏"))
,((mod4Mask, xK_d), (windows $ W.view "d:☺"))
,(((mod4Mask .|. shiftMask), xK_d), (windows $ W.shift "d:☺"))
,((mod4Mask, xK_f), (windows $ W.view "f:⌂"))
,(((mod4Mask .|. shiftMask), xK_f), (windows $ W.shift "f:⌂"))
-- should learn some more haskell to do this right
,((mod4Mask, xK_1), (windows $ W.view "1"))
--,((mod4Mask, xK_KP_End), (windows $ W.view "1"))
,((mod4Mask, xK_2), (windows $ W.view "2"))
--,((mod4Mask, xK_KP_Down), (windows $ W.view "2"))
,((mod4Mask, xK_3), (windows $ W.view "3"))
--,((mod4Mask, xK_KP_Page_Down), (windows $ W.view "3"))
,((mod4Mask, xK_4), (windows $ W.view "4"))
--,((mod4Mask, xK_KP_Left), (windows $ W.view "4"))
,((mod4Mask, xK_5), (windows $ W.view "5"))
--,((mod4Mask, xK_KP_Begin), (windows $ W.view "5"))
,((mod4Mask, xK_6), (windows $ W.view "6"))
--,((mod4Mask, xK_KP_Right), (windows $ W.view "6"))
,((mod4Mask, xK_7), (windows $ W.view "7"))
--,((mod4Mask, xK_KP_Home), (windows $ W.view "7"))
,((mod4Mask, xK_8), (windows $ W.view "8"))
--,((mod4Mask, xK_KP_Up), (windows $ W.view "8"))
,((mod4Mask, xK_9), (windows $ W.view "9"))
--,((mod4Mask, xK_KP_Page_Up), (windows $ W.view "9"))
,(((mod4Mask), xK_w), nextScreen)
--,((mod4Mask, xK_u), moveTo Next NonEmptyWS)
--,((mod4Mask .|. shiftMask, xK_u), moveTo Prev NonEmptyWS)
,((mod4Mask, xK_i), moveTo Next EmptyWS)
--,((mod4Mask, xK_Tab), nextWS)
--,((mod4Mask .|. shiftMask, xK_Tab), prevWS)
,((mod4Mask, xK_KP_Page_Down), nextWS)
,((mod4Mask, xK_KP_End), prevWS)
--,(((mod4Mask .|. shiftMask), xK_Shift_Lock), cycleRecentWS)
,((mod4Mask, xK_KP_Left), cycleRecentWS [xK_Super_L] xK_KP_Left xK_KP_Right)
,((mod4Mask, xK_KP_Right), cycleRecentWS [xK_Super_L] xK_KP_Left xK_KP_Right)
--,((mod4Mask, xK_Tab), cycleRecentWS [xK_Super_L] xK_Tab xK_grave)
-- TODO: add forward version!
]
-- does not work?
keysToDel x = [
--((mod4Mask .|. shiftMask), xK_q)
((mod4Mask), xK_Tab)
,((mod4Mask .|. shiftMask), xK_Tab)
,((mod4Mask), xK_w)
,((mod4Mask), xK_1)
,((mod4Mask), xK_2)
,((mod4Mask), xK_3)
,((mod4Mask), xK_4)
,((mod4Mask), xK_5)
,((mod4Mask), xK_6)
,((mod4Mask), xK_7)
,((mod4Mask), xK_8)
,((mod4Mask), xK_9)]
oldKeys x = foldr M.delete (keys defaultConfig x) (keysToDel x)
-- newKeys x = M.union (keys defaultConfig x) (M.fromList (keysToAdd x))
myKeys x = M.union (oldKeys x) (M.fromList (keysToAdd x))
--
myLayout = avoidStruts $ smartBorders (
onWorkspace "1" stdlayout $ -- no idea, why this is necessary :(
onWorkspace "9" movieLayout $
onWorkspace "a:✉" mailLayout $
onWorkspace "s:☏" webLayout $
onWorkspace "d:☺" pidginLayout $
onWorkspace "f:⌂" logLayout $
stdlayout )
where
-- default tiling algorithm partitions the screen into two panes
stdlayout = tiledTwo ||| noBorders Full
tiled = Tall nmaster delta ratio
tiledTwo = Tall nmaster delta ratioGold
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
ratioGold = 2/(3.5)
-- Percent of screen to increment by when resizing panes
delta = 3/100
-- gridLayout = spacing 8 $ Grid
pidginLayout = withIM (18/100) (Role "buddy_list") Grid
movieLayout = noBorders Full
-- mailLayout = simpleTabbed ||| tiledTwo
-- mailLayout = combineTwoP (TwoPane 0.03 0.5) (Full) (simpleTabbed) (Role "3pane")
mailLayout = withIM ratioGold (Role "3pane") (Grid ||| trackFloating simpleTabbed)
webLayout = tiledTwo ||| Roledex ||| noBorders Full
logLayout = withIM ratioGold (ClassName "Gnome-logs") tiled
myStartupHook = do
spawnOnce "gnome-logs"
spawnOnce "keepassx"
spawnOnce "chromium"
spawnOnce "pidgin"
spawnOnce "thunderbird"
main :: IO ()
main = do
xmonad =<< xmobar (ewmh defaultConfig
{ terminal = "/usr/bin/terminator"
, workspaces = myWorkspaces
, modMask = mod4Mask
, borderWidth = 3
, manageHook = (isFullscreen --> doFullFloat) <+> (manageSpawn <+> myManageHook) <+>
manageHook defaultConfig
, layoutHook = myLayout
, keys = myKeys
, startupHook = myStartupHook
, handleEventHook = handleEventHook def <+> XMonad.Hooks.EwmhDesktops.fullscreenEventHook
})