From 4b20878d5f97d821c407fe2460e039d9a1d64eb1 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Sat, 10 Sep 2022 23:49:11 +0300 Subject: [PATCH] home/xmonad: keybindings cosmetic changes --- home/ui/xmonad/config.hs | 160 +++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 74 deletions(-) diff --git a/home/ui/xmonad/config.hs b/home/ui/xmonad/config.hs index ef3bee0..b3c30a7 100644 --- a/home/ui/xmonad/config.hs +++ b/home/ui/xmonad/config.hs @@ -48,11 +48,9 @@ import XMonad.Util.Run myTerminal = "alacritty" -- Whether focus follows the mouse pointer. -myFocusFollowsMouse :: Bool myFocusFollowsMouse = False -- Whether clicking on a window to focus also passes the click to the window -myClickJustFocuses :: Bool myClickJustFocuses = False -- Width of the window border in pixels. @@ -251,79 +249,93 @@ myManageHook = manageApps -- Key bindings. Add, modify or remove key bindings here. -- myKeys conf = - mkKeymap conf $ - -- launch a terminal - [ ("M-S-", spawn $ XMonad.terminal conf), - -- launch a 'flameshot' to screenshot - ("M-S-s", safeSpawn "flameshot" ["gui"]), - -- launch 'librewolf' browser - ("M-S-b", spawn "librewolf"), - -- launch 'dmenu_run' to choose applications - ("M-p", spawn "dmenu_run"), - -- close focused window - ("M4-S-c", kill), - -- Rotate through the available layout algorithms - ("M-", cycleThroughLayouts ["Full", "Mirror Spacing Tall"]), - ("M-", cycleThroughLayouts ["Spacing ThreeCol", "Spacing Tall", "Mirror Spacing Tall"]), - -- Reset the layouts on the current workspace to default - ("M-S-", setLayout $ XMonad.layoutHook conf), - -- Resize viewed windows to the correct size - ("M-n", refresh), - -- Easy moution to focus windows - ("M-s", selectWindow easyMotionConfig >>= (`whenJust` windows . W.focusWindow)), - -- Move focus to the next window - ("M-j", windows W.focusDown), - -- Move focus to the previous window - ("M-k", windows W.focusUp), - -- Move focus to the master window - ("M-m", windows W.focusMaster), - -- Swap the focused window and the master window - ("M-", windows W.swapMaster), - -- Swap the focused window with the next window - ("M-S-j", windows W.swapDown), - -- Swap the focused window with the previous window - ("M-S-k", windows W.swapUp), - -- Shrink the master area - ("M-h", sendMessage Shrink), - -- Expand the master area - ("M-l", sendMessage Expand), - -- Push window back into tiling - ("M-t", withFocused $ windows . W.sink), - -- Increment the number of windows in the master area - ("M-,", sendMessage $ IncMasterN 1), - -- Deincrement the number of windows in the master area - ("M-.", sendMessage $ IncMasterN (-1)), - -- Toggle the status bar gap - -- Use this binding with avoidStruts from Hooks.ManageDocks. - -- See also the statusBar function from Hooks.DynamicLog. - -- - -- , ("M-b", sendMessage ToggleStruts) + let easyMotionConfig = + def + { sKeys = AnyKeys [xK_a, xK_o, xK_e, xK_u, xK_h, xK_t, xK_n, xK_s] + } - -- Lock screen - ("M4-l", spawn "betterlockscreen --lock --display 1 -- -e"), - -- Change volume - ("", spawn "amixer -q sset Master toggle"), - ("", spawn "amixer -q sset Master 5%+"), - ("", spawn "amixer -q sset Master 5%-"), - -- Keyboard apps - ("", spawn "gnome-calculator"), - -- Quit xmonad - ("M4-S-q", io exitSuccess) - ] - ++ - -- - -- mod-[1..9], Switch to workspace N - -- mod-shift-[1..9], Move client to workspace N - -- - [ ("M-" ++ m ++ show k, windows $ f i) - | (i, k) <- zip (XMonad.workspaces conf) [1 .. 9], - (f, m) <- [(W.greedyView, ""), (W.shift, "S-")] - ] - where - easyMotionConfig = - def - { sKeys = AnyKeys [xK_a, xK_o, xK_e, xK_u, xK_h, xK_t, xK_n, xK_s] - } + apps_kb = + [ -- launch a terminal + ("M-S-", spawn $ XMonad.terminal conf), + -- launch a 'flameshot' to screenshot + ("M-S-s", safeSpawn "flameshot" ["gui"]), + -- launch 'librewolf' browser + ("M-S-b", spawn "librewolf"), + -- launch 'dmenu_run' to choose applications + ("M-p", spawn "dmenu_run") + -- Open calculator + -- ("", spawn "gnome-calculator"), + ] + + workspaces_kb = + -- + -- mod-[1..9], Switch to workspace N + -- mod-shift-[1..9], Move client to workspace N + -- + [ ("M-" ++ m ++ show k, windows $ f i) + | (i, k) <- zip (XMonad.workspaces conf) [1 .. 9], + (f, m) <- [(W.greedyView, ""), (W.shift, "S-")] + ] + + windows_kb = + [ -- close focused window + ("M4-S-c", kill), + -- Resize viewed windows to the correct size + ("M-n", refresh), + -- Easy moution to focus windows + ("M-s", selectWindow easyMotionConfig >>= (`whenJust` windows . W.focusWindow)), + -- Move focus to the next window + ("M-j", windows W.focusDown), + -- Move focus to the previous window + ("M-k", windows W.focusUp), + -- Move focus to the master window + ("M-m", windows W.focusMaster), + -- Swap the focused window and the master window + ("M-", windows W.swapMaster), + -- Swap the focused window with the next window + ("M-S-j", windows W.swapDown), + -- Swap the focused window with the previous window + ("M-S-k", windows W.swapUp) + ] + + layout_kb = + [ -- Rotate through the available layout algorithms + ("M-", cycleThroughLayouts ["Full", "Mirror Spacing Tall"]), + ("M-", cycleThroughLayouts ["Spacing ThreeCol", "Spacing Tall", "Mirror Spacing Tall"]), + -- Reset the layouts on the current workspace to default + ("M-S-", setLayout $ XMonad.layoutHook conf), + -- Shrink the master area + ("M-h", sendMessage Shrink), + -- Expand the master area + ("M-l", sendMessage Expand), + -- Push window back into tiling + ("M-t", withFocused $ windows . W.sink), + -- Increment the number of windows in the master area + ("M-,", sendMessage $ IncMasterN 1), + -- Deincrement the number of windows in the master area + ("M-.", sendMessage $ IncMasterN (-1)) + -- Toggle the status bar gap + -- Use this binding with avoidStruts from Hooks.ManageDocks. + -- See also the statusBar function from Hooks.DynamicLog. + -- + -- , ("M-b", sendMessage ToggleStruts) + ] + + system_kb = + [ -- Lock screen + ("M4-l", spawn "betterlockscreen --lock --display 1 -- -e"), + -- Quit xmonad + ("M4-S-q", io exitSuccess) + ] + + misc_kb = + [ -- Change volume + ("", spawn "amixer -q sset Master toggle"), + ("", spawn "amixer -q sset Master 5%+"), + ("", spawn "amixer -q sset Master 5%-") + ] + in mkKeymap conf $ + apps_kb ++ workspaces_kb ++ windows_kb ++ layout_kb ++ system_kb ++ misc_kb ------------------------------------------------------------------------ -- Mouse bindings: default actions bound to mouse events