From 86cdc12e4708c12c8c557def921e9ff1d407b34b Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Tue, 5 Jul 2016 09:25:35 -0400 Subject: Custom xmonad key bindings. --- xmonad/xmonad.hs | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) (limited to 'xmonad/xmonad.hs') diff --git a/xmonad/xmonad.hs b/xmonad/xmonad.hs index fdc6dd6..6d495e4 100644 --- a/xmonad/xmonad.hs +++ b/xmonad/xmonad.hs @@ -1,24 +1,138 @@ import XMonad +import XMonad.Config.Desktop import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run (spawnPipe) import XMonad.Util.EZConfig (additionalKeys) import XMonad.Layout.NoBorders import System.IO +import qualified XMonad.StackSet as W +import qualified Data.Map as M +import System.Exit main = do xmproc <- spawnPipe "/usr/bin/env xmobar /home/orbekk/.xmonad/xmobar.hs" - xmonad $ defaultConfig + xmonad $ desktopConfig { manageHook = manageDocks <+> manageHook defaultConfig , layoutHook = smartBorders . avoidStruts $ layoutHook defaultConfig , logHook = dynamicLogWithPP xmobarPP { ppOutput = hPutStrLn xmproc , ppTitle = xmobarColor "green" "" . shorten 50 } + , keys = myKeys , modMask = mod4Mask , terminal = "termite" , borderWidth = 2 } `additionalKeys` [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock") - , ((mod4Mask, xK_b), sendMessage ToggleStruts) ] + +myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ + + -- launch a terminal + [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) + + -- launch dmenu + , ((modm, xK_p ), spawn "dmenu_run") + + -- launch gmrun + , ((modm .|. shiftMask, xK_p ), spawn "gmrun") + + -- close focused window + , ((modm .|. shiftMask, xK_c ), kill) + + -- Rotate through the available layout algorithms + , ((modm, xK_space ), sendMessage NextLayout) + + -- Reset the layouts on the current workspace to default + , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) + + -- Resize viewed windows to the correct size + , ((modm, xK_n ), refresh) + + -- Move focus to the next window + -- , ((modm, xK_Tab ), windows W.focusDown) + + -- Move focus to the next window + , ((modm, xK_j ), windows W.focusDown) + + -- Move focus to the previous window + , ((modm, xK_k ), windows W.focusUp ) + + -- Move focus to the master window + , ((modm, xK_m ), windows W.focusMaster ) + + -- Swap the focused window and the master window + , ((modm, xK_Return), windows W.swapMaster) + + -- Swap the focused window with the next window + , ((modm .|. shiftMask, xK_j ), windows W.swapDown ) + + -- Swap the focused window with the previous window + , ((modm .|. shiftMask, xK_k ), windows W.swapUp ) + + -- Shrink the master area + , ((modm, xK_h ), sendMessage Shrink) + + -- Expand the master area + , ((modm, xK_l ), sendMessage Expand) + + -- Push window back into tiling + , ((modm, xK_t ), withFocused $ windows . W.sink) + + -- Increment the number of windows in the master area + -- , ((modm , xK_comma ), sendMessage (IncMasterN 1)) + , ((modm , xK_Tab ), sendMessage (IncMasterN 1)) + + -- Deincrement the number of windows in the master area + -- , ((modm , xK_period), sendMessage (IncMasterN (-1))) + , ((modm .|. shiftMask, xK_Tab ), sendMessage (IncMasterN (-1))) + + -- Toggle the status bar gap + -- Use this binding with avoidStruts from Hooks.ManageDocks. + -- See also the statusBar function from Hooks.DynamicLog. + -- + , ((modm , xK_b ), sendMessage ToggleStruts) + + -- Quit xmonad + -- , ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) + + -- Restart xmonad + -- , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart") + + -- Lock screen + , ((modm .|. shiftMask, xK_z), spawn "xscreensaver-command -lock") + ] + ++ + + -- + -- mod-[1..9], Switch to workspace N + -- mod-shift-[1..9], Move client to workspace N + -- + [((m .|. modm, k), windows $ f i) + | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] + , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] + ++ + + [((m .|. modm, k), windows $ f i) + | (i, k) <- zip (XMonad.workspaces conf) [ + xK_apostrophe + , xK_comma + , xK_period + , xK_p + , xK_y + , xK_a + , xK_o + , xK_e + , xK_u] + , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] + ++ + + -- + -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 + -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 + -- + [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) + | (key, sc) <- zip [xK_semicolon, xK_q, xK_r] [0..] + , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] + -- cgit v1.2.3