xmonad

After twm, ion3 I welcome xmonad as my window manager. Unlike Joey Hess, who describes the changing of a window manager as something that changes your way of conceptualising the windows, I have used them all more or less in the same way, with fullscreen windows.

If you want to try out this way: here is my .xmonad/xmonad.hs. It requires libghc6-xmonad-contrib-dev.

UPDATE:

  1. make sure windows appear at the workspace where I want them;
  2. Convenience short-cut Shift-mod3 F1 bound to a ssh session on my server. (I have more like that one, but they are not interesting to you).
  3. Use Grid to get same-sized windows when not in fullscreen mode.
import XMonad
import XMonad.Hooks.ManageHelpers

import XMonad.Actions.CycleWS

import qualified XMonad.StackSet as W
import qualified Data.Map as M

import XMonad.Layout.NoBorders
import XMonad.Layout.Grid

myKeys conf@(XConfig {modMask = modm}) = M.fromList $
    -- Remap switching workspaces to M-[jklnm;uio]
    [((m .|. modm, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) [xK_j, xK_k, xK_l, xK_f, xK_d, xK_u, xK_i, xK_o]
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
        ]

        ++
        [
        -- Restore some essential functions whose keybindings are now stolen
        ((modm .|. shiftMask,               xK_s), windows W.swapMaster)
        ]
        ++
        [

        -- launch dmenu (caps lock "x") as in eXecute
         ((modm,               xK_x     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")

        -- launch a terminal, ssh and screen into
         , ((modm .|. shiftMask,               xK_F1     ), spawn "x-terminal-emulator -e 'ssh -t code.cjb.net screen -D -R'")
        ]

        ++
        [

        --  -- -- a basic CycleWS setup
        ((modm,               xK_Down),  nextWS)
        , ((modm,               xK_n   ), windows W.focusDown)
        , ((modm,               xK_p   ), windows W.focusUp)
        , ((modm,               xK_Up),    prevWS)
        , ((modm .|. shiftMask, xK_Down),  shiftToNext)
        , ((modm .|. shiftMask, xK_Up),    shiftToPrev)
        , ((modm,               xK_Right), nextScreen)
        , ((modm,               xK_Left),  prevScreen)
        , ((modm .|. shiftMask, xK_Right), shiftNextScreen)
        , ((modm .|. shiftMask, xK_Left),  shiftPrevScreen)
        , ((modm,               xK_z),     toggleWS)

        ]

myManageHook  = composeAll [
              isKDETrayWindow --> doIgnore
              -- transience,
              ,resource =? "stalonetray" --> doIgnore
              ,isFullscreen --> doFullFloat
              ,className =? "Iceweasel"  --> doF (W.shift "4")
              ,className =? "Icedove"  --> doF (W.shift "3")
              ,className =? "Emacs"  --> doF (W.shift "1")
              ,className =? "XTerm"  --> doF (W.shift "2")
              ,className =? "Zathura"  --> doF (W.shift "7")
              ,className =? "OpenOffice.org 3.2"  --> doF (W.shift "8")
                       ]

-- myManageHook  = composeOne [
--               isKDETrayWindow -?> doIgnore,
--               transience,
--               isFullscreen -?> doFullFloat,
--               resource =? "stalonetray" -?> doIgnore
--                     ]
newManageHook = myManageHook <+> manageHook defaultConfig

myLayout = smartBorders ( Grid ||| Full )

main = xmonad $ defaultConfig { layoutHook = myLayout
        , borderWidth        = 2
        , modMask = mod3Mask     -- Rebind Mod to Caps lock
        , normalBorderColor  = "#cccccc"
        , focusedBorderColor = "#cd8b00"
        , keys = \c -> myKeys c `M.union` keys defaultConfig c
        , manageHook = newManageHook
}

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: 2011-07-28