aboutsummaryrefslogtreecommitdiff
path: root/.config/XMonad/lib/Keybindings.hs
blob: 6255626ae5e62d6ec3b5786fc57fd459413509eb (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
module Keybindings where

import XMonad
import qualified XMonad.StackSet as W

-- actions
import XMonad.Actions.CopyWindow
import XMonad.Actions.WithAll
import XMonad.Actions.CycleWS
import XMonad.Actions.GridSelect
import XMonad.Actions.SwapWorkspaces
import XMonad.Actions.FloatKeys
import qualified XMonad.Actions.FlexibleResize as Flex

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

-- Layouts
import XMonad.Layout.BinarySpacePartition as BSP

-- hooks
import XMonad.Hooks.ManageDocks

import Defaults
import TreeSelect
import Scratchpads

myMonitorKeys = [xK_m, xK_b]

myMouseKeybindings :: [((ButtonMask, Button), Window -> X ())]
myMouseKeybindings = [
    ((myModMask,        4), \w -> prevWS)
    , ((myModMask,      5), \w -> nextWS)
    , ((myModShiftMask, 4), \w -> shiftToPrev >> prevWS)
    , ((myModShiftMask, 5), \w -> shiftToNext >> nextWS)
    , ((myModMask, 3), \w -> focus w >> Flex.mouseResizeWindow w)
  ]

myFnKeybindingsP :: [(String, X())]
myFnKeybindingsP = [
    ("<XF86MonBrightnessUp>",     spawn backlightUp)
    , ("<XF86MonBrightnessDown>", spawn backlightDown)

    , ("<XF86AudioRaiseVolume>",  spawn volUp)
    , ("<XF86AudioLowerVolume>",  spawn volDown)
    , ("<XF86AudioMute>",         spawn volMute)

    , ("<XF86AudioPrev>",         spawn prevTrack)
    , ("<XF86AudioNext>",         spawn nextTrack)
    , ("<XF86AudioStop>",         spawn stopTrack)
    , ("<XF86AudioPlay>",         spawn pausePlay)
    , ("<XF86AudioPause>",        spawn pausePlay)
    , ("<Pause>",                 spawn pausePlay)

    , ("<XF86Mail>",              spawn myEmailClient)
    , ("<XF86HomePage>",          spawn myWallpaperMenu)
    , ("<XF86Explorer>",          spawn myDisplayMenu)
    , ("<XF86Calculator>",        spawn myCalculator)
  ]

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

    , ((myModMask,      xK_s), showTS myMainTS)
    , ((myModShiftMask, xK_s), spawn myLauncher)

    -- view prev/next workspaces
    , ((myModMask',              xK_h         ), prevWS)
    , ((myModMask',              xK_l         ), nextWS)

    -- move to prev/next workspaces
    , ((myModShiftMask', xK_h         ), shiftToPrev >> prevWS)
    , ((myModShiftMask', xK_l         ), shiftToNext >> nextWS)

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

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

    -- cycle through windows
    , ((myModMask,      xK_Tab), windows W.focusUp)
    , ((myModShiftMask, xK_Tab), windows W.focusDown)

    -- 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
    , ((myModShiftMask,              xK_l), sendMessage $ WN.Swap R)
    , ((myModShiftMask,              xK_h), sendMessage $ WN.Swap L)
    , ((myModShiftMask,              xK_k), sendMessage $ WN.Swap U)
    , ((myModShiftMask,              xK_j), sendMessage $ WN.Swap D)

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

    -- swapping screens
    -- TODO: find a way to do this with screen id directly, not prev/next
    , ((myModMask .|. controlMask, xK_m),  swapPrevScreen)
    , ((myModMask .|. controlMask, xK_b),  swapPrevScreen)
  ] ++ [
    -- workspace switching
    ((myModMask, key), windows $ W.view ws) 
    | (key,ws) <- myExtraWorkspaces
  ] ++ [
    -- moving window to workspace
    ((myModShiftMask, key), windows $ W.shift ws) 
    | (key,ws) <- myExtraWorkspaces
  ] ++ [
    -- to swap workspace
    ((myModShiftMask', key), windows $ swapWithCurrent ws) 
    | (key, ws) <- zip [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_8, xK_0] myWorkspaces
  ] ++ [
    -- copy windows to other workspaces
    ((myModShiftMask .|. controlMask, key), windows $ copy ws)
    | (key, ws) <- zip [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_8, xK_0] myWorkspaces
  ] ++ [ -- focusing another monitor
    ((myModMask, key), screenWorkspace sc >>= flip whenJust (windows . W.view))
    | (key, sc) <- zip myMonitorKeys [0..]
  ] ++ [ -- moving window to another monitor
    ((myModShiftMask, key), screenWorkspace sc >>= flip whenJust (windows . \x -> W.view x . W.shift x))
    | (key, sc) <- zip myMonitorKeys [0..]
  ] ++ [ -- swapping screens (doesn't do much in < 3 monitors)
    ((myModMask .|. controlMask, key), screenWorkspace sc >>= flip whenJust (windows . \x -> W.greedyView x))
    | (key, sc) <- zip myMonitorKeys [0..]
  ]

myKeybindingsP :: [(String, X())]
myKeybindingsP = [
  ] ++ [ -- move and resize floating windows
    ("M-" <> m <> k, withFocused $ f i)
    | (i, k) <- zip [U, D, R, L] ["<Up>", "<Down>", "<Right>", "<Left>"]
    , (f, m) <- [(directionMoveWindow 10, ""), (directionResizeWindow 10, "S-")]
  ]