aboutsummaryrefslogtreecommitdiff
path: root/.config/XMonad/lib/Keybindings.hs
blob: 84ebb7cb42b5a39824cc9294222399c749eeb96d (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
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
module Keybindings where
import XMonad
import XMonad.Operations
import qualified XMonad.StackSet as W
import System.Exit
import System.IO

-- data
import Data.Tree
import qualified Data.Map as M

-- actions
import XMonad.Actions.CopyWindow
import XMonad.Actions.WithAll
import XMonad.Actions.CycleWS
import XMonad.Actions.GridSelect
import XMonad.Actions.SwapWorkspaces
import qualified XMonad.Actions.TreeSelect as TS

-- layout modifiers
import XMonad.Layout.Spacing
import XMonad.Layout.WindowNavigation as WN
import XMonad.Layout.Maximize
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders

-- Layouts
import XMonad.Layout.BinarySpacePartition as BSP
import XMonad.Layout.Grid
import XMonad.Layout.Tabbed

-- hooks
import XMonad.Hooks.SetWMName
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops

import XMonad.Hooks.DynamicLog
-- DynamicLog replacement(s)
-- import XMonad.Hooks.StatusBar
-- import XMonad.Hooks.StatusBar.PP

-- utilities
import XMonad.Util.Run
import XMonad.Util.SpawnOnce
import XMonad.Util.EZConfig
import XMonad.Util.Cursor
import XMonad.Util.NamedScratchpad

import Defaults
import Scratchpads

myMouseKeybindings :: [((ButtonMask, Button), Window -> X ())]
myMouseKeybindings = [
    ((myModMask, 4), \w -> prevWS)
    , ((myModMask, 5), \w -> nextWS)
  ]

myKeybindings :: [((KeyMask, KeySym), X ())]
myKeybindings = [
    ((myModMask, xK_Return), spawn myTerminal)
    , ((myModMask .|. shiftMask, xK_q), kill1)
    , ((myModShiftMask, xK_p), spawn myLauncher)

    -- scratchpads
    , ((myModMask,      xK_u), myScratchpad "Term 0")
    , ((myModMask,      xK_i), myScratchpad "Term 1")
    , ((myModMask,      xK_o), myScratchpad "Term 2")
    , ((myModMask,      xK_p), myScratchpad "Term 3")

    -- volume keys , ((myModMask, xK_equal), spawn volUp)
    , ((myModMask, xK_minus),     spawn volDown)
    , ((myModMask, xK_BackSpace), spawn volMute)

    -- brightness keys
    , ((myModMask .|. shiftMask, xK_equal), spawn backlightUp)
    , ((myModMask .|. shiftMask, xK_minus), spawn backlightDown)

    -- modify gaps on runtime
    , ((myModMask,               xK_F2), incWindowSpacing 1)
    , ((myModMask,               xK_F1), decWindowSpacing 1)
    , ((myModMask .|. shiftMask, xK_F2), incScreenSpacing 1)
    , ((myModMask .|. shiftMask, xK_F1), decScreenSpacing 1)

    -- view prev/next workspaces
    , ((myModMask .|. shiftMask, xK_Tab       ), prevWS)
    , ((myModMask,               xK_Tab       ), nextWS)
    , ((myModMask,               xK_semicolon ), prevWS)
    , ((myModMask,               xK_apostrophe), nextWS)
    , ((myModMask',              xK_h         ), prevWS)
    , ((myModMask',              xK_l         ), nextWS)

    -- move to prev/next workspaces
    , ((myModMask' .|. shiftMask, xK_h         ), shiftToPrev >> prevWS)
    , ((myModMask' .|. shiftMask, xK_l         ), shiftToNext >> nextWS)
    , ((myModMask  .|. shiftMask, xK_semicolon ), shiftToPrev >> prevWS)
    , ((myModMask  .|. shiftMask, xK_apostrophe), shiftToNext >> nextWS)

    -- focus previous/next monitor
    , ((myModMask, xK_bracketleft ), prevScreen)
    , ((myModMask, xK_bracketright), nextScreen)

    -- move window to previous/next monitor
    , ((myModMask .|. shiftMask, xK_bracketleft ), shiftPrevScreen >> prevScreen)
    , ((myModMask .|. shiftMask, xK_bracketright), shiftNextScreen >> nextScreen)

    -- swap different screens
    , ((myModMask .|. controlMask, xK_bracketleft ), swapPrevScreen)
    , ((myModMask .|. controlMask, xK_bracketright), swapNextScreen)

    -- toggle maximize
    , ((myModMask, xK_f), withFocused (sendMessage . maximizeRestore))

    -- unfloat windows
    , ((myModMask .|. shiftMask, xK_f), withFocused $ windows . W.sink)

    -- cycle through windows
    , ((myModMask', xK_j), windows W.focusDown)
    , ((myModMask', xK_k), windows W.focusUp)

    -- 2D navigation
    , ((myModMask,               xK_l), sendMessage $ Go R)
    , ((myModMask,               xK_h), sendMessage $ Go L)
    , ((myModMask,               xK_k), sendMessage $ Go U)
    , ((myModMask,               xK_j), sendMessage $ Go D)

    -- swap windows
    , ((myModMask .|. shiftMask, xK_l), sendMessage $ WN.Swap R)
    , ((myModMask .|. shiftMask, xK_h), sendMessage $ WN.Swap L)
    , ((myModMask .|. shiftMask, xK_k), sendMessage $ WN.Swap U)
    , ((myModMask .|. shiftMask, xK_j), sendMessage $ WN.Swap D)

    -- resize
    , ((myModMask .|. mod1Mask,                 xK_l), sendMessage $ ExpandTowards R)
    , ((myModMask .|. mod1Mask,                 xK_h), sendMessage $ ExpandTowards L)
    , ((myModMask .|. mod1Mask,                 xK_j), sendMessage $ ExpandTowards D)
    , ((myModMask .|. mod1Mask,                 xK_k), sendMessage $ ExpandTowards U)
    , ((myModMask .|. mod1Mask .|. shiftMask,   xK_l), sendMessage $ ShrinkFrom R)
    , ((myModMask .|. mod1Mask .|. shiftMask,   xK_h), sendMessage $ ShrinkFrom L)
    , ((myModMask .|. mod1Mask .|. shiftMask,   xK_j), sendMessage $ ShrinkFrom D)
    , ((myModMask .|. mod1Mask .|. shiftMask,   xK_k), sendMessage $ ShrinkFrom U)

  ] ++ [ -- for extra workspace(s)
    ((myModMask, key), windows $ W.greedyView ws)
    | (key,ws) <- myExtraWorkspaces
  ] ++ [ -- also for extra workspaces
    ((myModMask .|. shiftMask, key), windows $ W.shift ws)
    | (key,ws) <- myExtraWorkspaces
  ] ++ [ -- to swap workspace
    ((mod1Mask .|. shiftMask, k), windows $ swapWithCurrent i)
    | (i, k) <- zip myWorkspaces [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9, xK_0]
  ] ++ [ -- copy
    ((m .|. myModMask, k), windows $ f i)
    | (i, k) <- zip myWorkspaces [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9, xK_0]
    , (f, m) <- [(copy, shiftMask .|. myModMask')]
  ] ++ [ -- for not swapping tags while using multihead
    ((m .|. myModMask, k), windows $ f i)
    | (i, k) <- zip myWorkspaces [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9, xK_0]
    , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
  ]

myKeybindingsP :: [(String, X())]
myKeybindingsP = [
    ("<XF86MonBrightnessUp>",     spawn backlightUp)
    , ("<XF86MonBrightnessDown>", spawn backlightDown)
    , ("<XF86AudioRaiseVolume>",  spawn volUp)
    , ("<XF86AudioLowerVolume>",  spawn volDown)
    , ("<XF86AudioMute>",         spawn volMute)
    -- actions
    -- TODO: add reboot, shutdown, logout, copy, cut, paste
    , ("M-a w",     spawn volMute)
    , ("M-a S-w",   spawn wifiOn)
    , ("M-a s",     spawn wifiOff)
    , ("M-a S-s",   spawn fullScreenshot)
    , ("M-a m",     spawn volMute)
    -- media
    , ("M-m w",     myScratchpad "wallpaper")
    , ("M-m o",     spawn "obs")
    , ("M-m S-o",   spawn "osu")
    , ("M-m s",     spawn "syncplay")
    , ("M-m g",     spawn "gimp")
    , ("M-m k",     spawn "kdenlive")
    , ("M-m l",     spawn "lutris")
    , ("M-m v",     spawn "vlc")
    , ("M-m m",     spawn "minecraft-launcher")
    -- system apps/scratchpads
    , ("M-b t",     spawn myTorrentClient)
    , ("M-b i",     spawn myBrowser)
    , ("M-b d",     myScratchpad "aarandr")
    , ("M-b c",     myScratchpad "calc")
    , ("M-b b",     myScratchpad "blueman")
    , ("M-b p",     myScratchpad "pavucontrol")
    , ("M-b m",     myScratchpad "BPYTOP")
    , ("M-b n",     myScratchpad "nmtui")
    -- websites
    , ("M-n y",     spawn $ myBrowser ++ " https://youtube.com")
    , ("M-n d",     spawn $ myBrowser ++ " https://duckduckgo.com")
    , ("M-n g",     spawn $ myBrowser ++ " https://google.com")
    , ("M-n S-g",   spawn $ myBrowser ++ " https://github.com")
    , ("M-n j",     spawn $ myBrowser ++ " https://www.youtube.com/playlist?list=PL8lRJQHQWddu55nsz8CezmJJ-GRVISZ1E")
    , ("M-n k",     spawn $ myBrowser ++ " https://www.youtube.com/playlist?list=PL8lRJQHQWddvzCv02lClCfDfUo97wzX1A")
    , ("M-n c",     spawn $ myBrowser ++ " https://www.youtube.com/playlist?list=PL8lRJQHQWdduy2V0DQQ4Lm0P572XJFVB9")
    , ("M-n v",     spawn $ myBrowser ++ " https://vidhukant.xyz")
    , ("M-n S-v",   spawn $ myBrowser ++ " https://blog.vidhukant.xyz")
    , ("M-n m",     spawn $ myBrowser ++ " https://myanimelist.net/profile/0ZeroTsu")
    -- other apps
    -- TODO: add scrcpy
    , ("M-y t",     spawn myTorrentClient)
    , ("M-y S-t",   spawn "torbrowser-launcher")
    , ("M-y i",     spawn myBrowser)
    , ("M-y d",     spawn "discord")
    , ("M-y f",     spawn "firefox")
    , ("M-y v",     spawn "virt-manager")
    , ("M-y b",     spawn "brave")
    , ("M-y p",     spawn myFileManager)
    , ("M-y S-p",   spawn $ myTerminal' ++ " -e " ++ myFileManager')
    -- XMonad
    , ("M-q q",     gridselectWindow myGridSelect >>= flip whenJust (\w -> killWindow w))
    , ("M-q S-q",   killAll)
    , ("M-q r",     sendMessage Rotate)
    , ("M-q t",     sendMessage ToggleStruts)
    , ("M-q s",     sendMessage BSP.Swap)
    , ("M-q g",     goToSelected myGridSelect)
    , ("M-q x d",   decWindowSpacing 3)
    , ("M-q x i",   incWindowSpacing 3)
    , ("M-q x S-d", decScreenSpacing 3)
    , ("M-q x S-i", incScreenSpacing 3)
    , ("M-q x b",   setSmartSpacing False)
    , ("M-q x S-b", setSmartSpacing True)
    , ("M-q x n",   setWindowSpacingEnabled False)
    , ("M-q x S-n", setWindowSpacingEnabled True)
    , ("M-q x m",   setScreenSpacingEnabled False)
    , ("M-q x S-m", setScreenSpacingEnabled True)
    , ("M-q c",     windows copyToAll)
    , ("M-q S-c",   killAllOtherCopies)
    , ("M-q b",     bringSelected myGridSelect)
    -- resize windows
    , ("M-q h",     sendMessage $ ExpandTowards L)
    , ("M-q j",     sendMessage $ ExpandTowards D)
    , ("M-q k",     sendMessage $ ExpandTowards U)
    , ("M-q l",     sendMessage $ ExpandTowards R)
    , ("M-q S-h",   sendMessage $ ShrinkFrom L)
    , ("M-q S-j",   sendMessage $ ShrinkFrom D)
    , ("M-q S-k",   sendMessage $ ShrinkFrom U)
    , ("M-q S-l",   sendMessage $ ShrinkFrom R)
  ]