From 6521976d2ffcb9162b4b6f4d4d94e80ce57c9a86 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 3 Jan 2021 20:57:33 +0530 Subject: synced keybindings with awesome and added maximize window functionality --- XMonad/xmonad.hs | 164 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 108 insertions(+), 56 deletions(-) (limited to 'XMonad/xmonad.hs') diff --git a/XMonad/xmonad.hs b/XMonad/xmonad.hs index e08d987c..454dd4c1 100644 --- a/XMonad/xmonad.hs +++ b/XMonad/xmonad.hs @@ -15,6 +15,8 @@ import XMonad.Actions.MouseResize import XMonad.Layout.Spacing import XMonad.Layout.LayoutModifier import XMonad.Layout.WindowNavigation as WN +import XMonad.Layout.Fullscreen +import XMonad.Layout.Renamed (renamed, Rename(Replace)) -- Layouts -- import XMonad.Layout.AvoidFloats @@ -25,7 +27,8 @@ import XMonad.Layout.ThreeColumns import XMonad.Layout.TwoPane import XMonad.Layout.Spiral import XMonad.Layout.ResizableTile -import XMonad.Layout.Tabbed +import XMonad.Layout.Maximize +-- import XMonad.Layout.Tabbed -- hooks import XMonad.Hooks.SetWMName @@ -60,9 +63,12 @@ windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace -- defaults -myModMask :: KeyMask +-- myModMask :: KeyMask myModMask = mod4Mask +altMask :: KeyMask +altMask = mod1Mask + myTerminal :: String myTerminal = "st" @@ -72,9 +78,33 @@ myLauncher = "run_dmenu" myBrowser :: String myBrowser = "firefox" +myFileManager :: String +myFileManager = "pcmanfm" + +myEmailClient :: String +myEmailClient = "thunderbird" + myEditor :: String myEditor = "nvim" +myLockscreen :: String +myLockscreen = "betterlockscreen -l -t 'Yo, Vidhu!'" + +myScreenshot :: String +myScreenshot = "scrot /zt/Screenshots/Screenshot-%Y-%d-%m--%T.png" + + + +-- volume +myVolUp :: String +myVolUp = "pulseaudio-ctl up" + +myVolDown :: String +myVolDown = "pulseaudio-ctl down" + +myVolMute :: String +myVolMute = "pulseaudio-ctl mute" + -- wm variables nBorder = "#000000" -- "#3804f4" -- "#bf00ff" @@ -94,95 +124,106 @@ myWorkspaces = [" 一 "," 二 "," 三 "," 四 "," 五 "," 六 "," myScratchpads = [ -- NS "Vysor" "Vysor.AppImage" (title =? "Vysor") defaultFloating NS "Phone" "scrcpy" (title =? "Motorola One Power") defaultFloating, - NS "T1" "st -t 'T1'" (title =? "T1") defaultFloating, - NS "T2" "st -t 'T2'" (title =? "T2") defaultFloating, + NS "Terminal" "st -t 'TerminalScratchpad'" (title =? "TerminalScratchpad") defaultFloating, NS "Nitrogen" "nitrogen" (title =? "Nitrogen") defaultFloating ] where role = stringProperty "WM_WINDOW_ROLE" -- keybindings myKeys = [ - ((mod4Mask, xK_Return), spawn (myTerminal)) - , ((mod4Mask, xK_p), spawn "/home/zt/.config/scripts/run_dmenu") + ((myModMask, xK_Return), spawn (myTerminal)) + , ((myModMask, xK_p), spawn (myLauncher)) + , ((myModMask .|. shiftMask, xK_Return), spawn (myScreenshot)) +-- , ((myModMask, xK_q), spawn (myLockscreen)) + , ((mod1Mask, xK_w), kill1) , ((mod1Mask .|. shiftMask, xK_k), kill1) - , ((mod1Mask, xK_o), withFocused $ windows . W.sink) -- unfloat windows + , ((myModMask, xK_a), withFocused $ windows . W.sink) -- unfloat windows + + -- launch apps/execute scripts + , ((myModMask, xK_i), spawn (myBrowser)) + , ((myModMask, xK_o), spawn (myFileManager)) + , ((myModMask, xK_y), spawn ("gimp")) + , ((myModMask, xK_e), spawn (myEmailClient)) + , ((myModMask, xK_m), spawn ("vlc")) + , ((myModMask, xK_b), spawn ("konqueror")) + + -- volume + , ((altMask, xK_0), spawn (myVolMute)) + , ((altMask, xK_minus), spawn (myVolDown)) + , ((altMask, xK_equal), spawn (myVolUp)) -- scratchpad keybindings - , ((mod4Mask, xK_p), namedScratchpadAction myScratchpads "Phone") - , ((mod4Mask, xK_o), namedScratchpadAction myScratchpads "T1") - , ((mod4Mask, xK_i), namedScratchpadAction myScratchpads "T2") - , ((mod4Mask, xK_w), namedScratchpadAction myScratchpads "Nitrogen") + , ((myModMask, xK_u), namedScratchpadAction myScratchpads "Phone") + , ((myModMask, xK_t), namedScratchpadAction myScratchpads "Terminal") + , ((myModMask, xK_w), namedScratchpadAction myScratchpads "Nitrogen") -- view prev/next workspaces - , ((mod1Mask, xK_h), prevWS) - , ((mod1Mask, xK_l), nextWS) + , ((altMask, xK_h), prevWS) + , ((altMask, xK_l), nextWS) -- move to prev/next workspaces - , ((mod1Mask .|. shiftMask, xK_h), shiftToPrev >> prevWS) - , ((mod1Mask .|. shiftMask, xK_l), shiftToNext >> nextWS) + , ((altMask .|. shiftMask, xK_h), shiftToPrev >> prevWS) + , ((altMask .|. shiftMask, xK_l), shiftToNext >> nextWS) -- modify gaps on runtime - , ((mod4Mask, xK_equal), incWindowSpacing 1) - , ((mod4Mask, xK_minus), decWindowSpacing 1) - , ((mod4Mask .|. shiftMask, xK_equal), incScreenSpacing 1) - , ((mod4Mask .|. shiftMask, xK_minus), decScreenSpacing 1) + , ((myModMask, xK_equal), incWindowSpacing 1) + , ((myModMask, xK_minus), decWindowSpacing 1) + , ((myModMask .|. shiftMask, xK_equal), incScreenSpacing 1) + , ((myModMask .|. shiftMask, xK_minus), decScreenSpacing 1) -- Swap the focused window and the master window , ((mod1Mask .|. shiftMask, xK_Return), windows W.swapMaster) -- these keybindings are for WindowNavigation -- and they conflict with BSP layout - -- directional navigation of windows - , ((mod4Mask, xK_l), sendMessage $ Go R) - , ((mod4Mask, xK_h), sendMessage $ Go L) - , ((mod4Mask, xK_k), sendMessage $ Go U) - , ((mod4Mask, xK_j), sendMessage $ Go D) + , ((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 - , ((mod4Mask .|. shiftMask, xK_l), sendMessage $ WN.Swap R) - , ((mod4Mask .|. shiftMask, xK_h), sendMessage $ WN.Swap L) - , ((mod4Mask .|. shiftMask, xK_k), sendMessage $ WN.Swap U) - , ((mod4Mask .|. shiftMask, xK_j), sendMessage $ WN.Swap D) + , ((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) -- cycle through windows - , ((mod1Mask, xK_j), windows W.focusDown) - , ((mod1Mask, xK_k), windows W.focusUp) + , ((altMask, xK_j), windows W.focusDown) + , ((altMask, xK_k), windows W.focusUp) -- grid select - , ((mod4Mask, xK_n), goToSelected defaultGSConfig) + , ((myModMask, xK_g), goToSelected defaultGSConfig) -- windowbringer - , ((mod4Mask, xK_b), bringMenu) - , ((mod4Mask, xK_g), gotoMenu) + , ((myModMask, xK_b), bringMenu) +-- , ((myModMask, xK_g), gotoMenu) -- paste x selection - , ((mod1Mask, xK_v), pasteSelection) + , ((altMask, xK_v), pasteSelection) -- toggle bars - , ((mod4Mask, xK_backslash), sendMessage ToggleStruts) -- toggle both bars - , ((mod4Mask, xK_bracketleft), sendMessage $ ToggleStrut D) -- toggle bottom bar - , ((mod4Mask, xK_bracketright), sendMessage $ ToggleStrut U) -- toggle top bar + , ((myModMask, xK_backslash), sendMessage ToggleStruts) -- toggle both bars + , ((myModMask, xK_bracketleft), sendMessage $ ToggleStrut D) -- toggle bottom bar + , ((myModMask, xK_bracketright), sendMessage $ ToggleStrut U) -- toggle top bar -- BSP layout keybindings -- resize - , ((mod4Mask .|. mod1Mask, xK_l ), sendMessage $ ExpandTowards R) - , ((mod4Mask .|. mod1Mask, xK_h ), sendMessage $ ExpandTowards L) - , ((mod4Mask .|. mod1Mask, xK_j ), sendMessage $ ExpandTowards D) - , ((mod4Mask .|. mod1Mask, xK_k ), sendMessage $ ExpandTowards U) - , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_l ), sendMessage $ ShrinkFrom R) - , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_h ), sendMessage $ ShrinkFrom L) - , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_j ), sendMessage $ ShrinkFrom D) - , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_k ), sendMessage $ ShrinkFrom U) + , ((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) -- other - , ((mod4Mask, xK_r ), sendMessage Rotate) - , ((mod4Mask, xK_s ), sendMessage BSP.Swap) --- , ((mod4Mask .|. shiftMask .|. controlMask , xK_j ), sendMessage $ SplitShift Prev) --- , ((mod4Mask .|. shiftMask .|. controlMask , xK_k ), sendMessage $ SplitShift Next) - - - + , ((myModMask, xK_d ), sendMessage Rotate) + , ((myModMask, xK_s ), sendMessage BSP.Swap) +-- , ((myModMask .|. shiftMask .|. controlMask , xK_j ), sendMessage $ SplitShift Prev) +-- , ((myModMask .|. shiftMask .|. controlMask , xK_k ), sendMessage $ SplitShift Next) + , ((myModMask, xK_f), withFocused (sendMessage . maximizeRestore)) ] ++ [ -- for extra workspace(s) ((myModMask, key), (windows $ W.greedyView ws)) | (key,ws) <- myExtraWorkspaces @@ -202,8 +243,19 @@ myKeys = [ -- layouts myGap = spacingRaw False (Border sGap sGap sGap sGap) True (Border wGap wGap wGap wGap) True - -myLayouts = avoidStruts $ mouseResize $ windowNavigation $ myGap $ emptyBSP ||| ThreeColMid 1 (3/100) (1/2) ||| Grid ||| TwoPane (3/100) (1/2) ||| ThreeCol 1 (3/100) (1/2) ||| ThreeCol 2 (3/100) (1/2) + + + + + +myLayouts = avoidStruts ( + renamed [Replace "BSP"] (maximize $ windowNavigation $ myGap $ emptyBSP) + ||| renamed [Replace "ThreeCol Mid"] (maximize $ windowNavigation $ myGap $ ThreeColMid 1 (3/100) (1/2)) + ||| renamed [Replace "Grid"] (maximize $ windowNavigation $ myGap $ Grid) + ||| renamed [Replace "TwoPane"] (maximize $ windowNavigation $ myGap $ TwoPane (3/100) (1/2)) + ||| renamed [Replace "ThreeCol (1)"] (maximize $ windowNavigation $ myGap $ ThreeCol 1 (3/100) (1/2)) + ||| renamed [Replace "ThreeCol (2)"] (maximize $ windowNavigation $ myGap $ ThreeCol 2 (3/100) (1/2)) + ) myLayoutHook = myLayouts @@ -233,8 +285,8 @@ main = do focusedBorderColor = fBorder, -- mouseBindings = myMouseBindings, layoutHook = myLayoutHook, - manageHook = namedScratchpadManageHook myScratchpads, - -- handleEventHook = myEventHook, + manageHook = namedScratchpadManageHook myScratchpads, + handleEventHook = fullscreenEventHook, logHook = dynamicLogWithPP myLemonbarPP { ppOutput = \x -> hPutStrLn notXMobar x}, startupHook = myStartupHook } `additionalKeys` myKeys -- cgit v1.2.3