diff options
author | Vidhu Kant Sharma <vidhukant@protonmail.ch> | 2022-05-20 21:45:12 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@protonmail.ch> | 2022-05-20 21:45:12 +0530 |
commit | b0ad81e7ba9407cc49b245f4f32d94495f86421c (patch) | |
tree | dc1e52b10a2e731d00dc0087b08c64a571f32aa6 /.config/XMonad/lib/Keybindings.hs | |
parent | 4c82a12dd261a9f09e7bddbf2d6e1f92f3246472 (diff) |
Modularised my XMonad Config
Diffstat (limited to '.config/XMonad/lib/Keybindings.hs')
-rw-r--r-- | .config/XMonad/lib/Keybindings.hs | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/.config/XMonad/lib/Keybindings.hs b/.config/XMonad/lib/Keybindings.hs new file mode 100644 index 0000000..b92fc97 --- /dev/null +++ b/.config/XMonad/lib/Keybindings.hs @@ -0,0 +1,170 @@ +module Keybindings where + +import XMonad +import qualified XMonad.StackSet as W +import XMonad.ManageHook +import System.Exit +import System.IO + +-- data +import Data.Tree +import qualified Data.Map as M + +-- actions +import XMonad.Actions.CopyWindow +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 = [ + ((myModMask, 4), \w -> prevWS) + , ((myModMask, 5), \w -> nextWS) + ] + +myKeybindings = [ + ((myModMask, xK_Return), spawn ("open_terminal")) + , ((myModMask .|. shiftMask, xK_q), kill1) + + -- 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) + , ((altMask, xK_h), prevWS) + , ((altMask, xK_l), nextWS) + + -- move to prev/next workspaces + , ((altMask .|. shiftMask, xK_h), shiftToPrev >> prevWS) + , ((altMask .|. 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) + + , ((myModMask, xK_a), sendMessage ToggleStruts) -- toggle both bars + , ((myModMask, xK_f), withFocused (sendMessage . maximizeRestore)) -- toggle maximize + , ((myModMask .|. shiftMask, xK_f), withFocused $ windows . W.sink) -- unfloat windows + + -- cycle through windows + , ((altMask, xK_j), windows W.focusDown) + , ((altMask, 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 .|. altMask)] + ] ++ [ -- 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 = [ + -- fn keys + -- ("<XF86MonBrightnessUp>", spawn backlightUp) + -- , ("<XF86MonBrightnessDown>", spawn backlightDown) + -- , ("<XF86AudioRaiseVolume>", spawn volUp) + -- , ("<XF86AudioLowerVolume>", spawn volDown) + -- , ("<XF86AudioMute>", spawn volMute) + -- ("M-S-p", spawn "dmenu_run") + -- scratchpads + -- , ("M-r", namedScratchpadAction myScratchpads "Term 0") + -- , ("M-t", namedScratchpadAction myScratchpads "Term 1") + -- , ("M-y", namedScratchpadAction myScratchpads "Term 2") + -- , ("M-u", namedScratchpadAction myScratchpads "Term 3") + -- , ("M-m", namedScratchpadAction myScratchpads "BPYTOP") + -- , ("M-S-m", namedScratchpadAction myScratchpads "calc") + -- , ("M-n", namedScratchpadAction myScratchpads "pavucontrol") + -- , ("M-S-n", namedScratchpadAction myScratchpads "arandr") + -- , ("M-b", namedScratchpadAction myScratchpads "blueman") + -- , ("M-S-r", namedScratchpadAction myScratchpads "wallpaper") + ] |