-- -- ~/.xmonad/xmonad.hs -- validate syntax: $ ghci ~/.xmonad/xmonad.hs -- -- import the necessary libraries import XMonad import XMonad.ManageHook import XMonad.Operations import XMonad.Actions.CycleWS import XMonad.Actions.DwmPromote import XMonad.Actions.RotSlaves import XMonad.Actions.SinkAll import XMonad.Hooks.DynamicLog ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP ) import XMonad.Hooks.ManageDocks import XMonad.Layout import XMonad.Layout.Grid import XMonad.Layout.NoBorders ( noBorders, smartBorders ) import XMonad.Layout.ToggleLayouts import XMonad.Prompt import XMonad.Prompt.AppendFile import XMonad.Prompt.Shell import XMonad.Prompt.Ssh import XMonad.Util.Run import qualified XMonad.StackSet as W import qualified XMonad.Actions.FlexibleResize as Flex import qualified Data.Map as M import Data.Bits ((.|.)) import Data.Ratio import Graphics.X11 import System.IO statusBarCmd= "dzen2 -bg '#222222' -fg '#777777' -h 16 -w 550 -sa c -e '' -fn '-*-glisp-*-*-*-*-*-*-*-*-*-*-*-*' -ta l" main = do din <- spawnPipe statusBarCmd xmonad $ defaultConfig { borderWidth = 2 , normalBorderColor = "#111111" , focusedBorderColor = "#0066ff" , workspaces = ["1:main", "2:www"] ++ map show [3 .. 9 :: Int] , terminal = "urxvt" , modMask = mod4Mask -- , defaultGaps = [(16,0,0,0)] , manageHook = manageHook defaultConfig <+> myManageHook <+> manageDocks , logHook = dynamicLogWithPP $ myPP din , layoutHook = avoidStruts $ toggleLayouts (noBorders Full) $ smartBorders (tiled ||| Mirror tiled ||| Full ||| Grid) , keys = \c -> myKeys c `M.union` keys defaultConfig c , mouseBindings = \c -> myMouse c `M.union` mouseBindings defaultConfig c } where tiled = Tall nmaster delta ratio -- The default number of windows in the master pane nmaster = 1 -- Default proportion of screen occupied by master pane ratio = 2/(1+(toRational(sqrt(5)::Double))) -- golden -- Percent of screen to increment by when resizing panes delta = 5%100 -- application control -- myManageHook :: ManageHook myManageHook = composeAll . concat $ [ [ className =? c --> doFloat | c <- myFloats] , [ title =? t --> doFloat | t <- myOtherFloats] , [ resource =? r --> doIgnore | r <- myIgnores] , [ className =? "Firefox-bin" --> doF (W.shift "2:www") ] , [ className =? "Opera" --> doF (W.shift "2:www") ] ] where myIgnores = ["panel", "stalonetray", "trayer"] myFloats = ["Transmission", "Transfer Files", "Revelation", "feh", "GIMP", "gimp", "Galculator", "VirtualBox", "VBoxSDL", "bluej-Boot"] myOtherFloats = ["alsamixer", "Bon Echo Preferences", "Mail/News Preferences", "Bon Echo - Restore Previous Session", "Downloads", "Gajim", "Available Status Message", "Create a new archive"] -- modify/add default key binds -- myKeys (XConfig {modMask = modm}) = M.fromList $ [ -- custom dmenu ((modm, xK_p), spawn "exe=`dmenu_path | dmenu -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -nb '#000000' -nf '#FFFFFF' -sb '#0066ff'` && eval \"exec $exe\"") -- %! Launch dmenu -- sink all floating windows , ((modm .|. shiftMask, xK_t), sinkAll) -- swap focused with master, or master with next in line , ((modm, xK_Return), dwmpromote) , ((mod1Mask, xK_Return), dwmpromote) , ((modm, xK_KP_Enter), dwmpromote) -- rotate slave clients , ((modm .|. shiftMask, xK_Tab ), rotSlavesUp) -- cycle and/or move clients through non-empty workspaces , ((modm, xK_Up), nextWS) , ((modm, xK_Down), prevWS) , ((modm .|. shiftMask, xK_Up), shiftToNext >> nextWS) , ((modm .|. shiftMask, xK_Down), shiftToPrev >> prevWS) , ((modm .|. controlMask, xK_Up), moveTo Next NonEmptyWS) , ((modm .|. controlMask, xK_Down), moveTo Prev NonEmptyWS) , ((modm, xK_Right), nextScreen) , ((modm, xK_Left), prevScreen) , ((modm .|. shiftMask, xK_Right), shiftToNext >> nextScreen) , ((modm .|. shiftMask, xK_Left), shiftToPrev >> prevScreen) -- toggle previous workspace , ((modm, xK_z), toggleWS) -- toggle fullscreen , ((modm, xK_x), sendMessage ToggleLayout) -- session management , ((mod1Mask .|. shiftMask .|. controlMask, xK_k), spawn "xkill") , ((mod1Mask .|. controlMask, xK_End), spawn "sudo shutdown -h now") , ((mod1Mask .|. controlMask, xK_Delete), spawn "sudo shutdown -r now") , ((controlMask .|. mod1Mask, xK_l), spawn "xscreensaver-command --lock") -- application hotkeys , ((mod4Mask, xK_w), spawn "firefox") , ((mod4Mask, xK_e), spawn "urxvt -e mutt") , ((mod4Mask, xK_f), spawn "nautilus") , ((mod4Mask, xK_v), spawn "urxvt -e alsamixer") , ((0, xK_Print), spawn "scrot %Y%m%d-dublin.png -t 280x175") , ((shiftMask, xK_Print), spawn "scrot %Y%m%d-dublin.png -d 3 -t 280x175") -- prompts , ((modm .|. controlMask, xK_s), sshPrompt defaultXPConfig) , ((modm .|. controlMask, xK_x), shellPrompt defaultXPConfig) , ((mod4Mask, xK_n), appendFilePrompt defaultXPConfig "/home/thayer/pkg-install-log") ] -- modify/add default mouse binds -- myMouse (XConfig {modMask = modm}) = M.fromList $ [ ((modm, button3), (\w -> focus w >> Flex.mouseResizeWindow w)) , ((modm .|. controlMask, button4), (\_ -> moveTo Next NonEmptyWS)) , ((modm .|. controlMask, button5), (\_ -> moveTo Prev NonEmptyWS)) , ((modm, button4), (\_ -> nextWS)) , ((modm, button5), (\_ -> prevWS)) ] -- dynamiclog pretty printer for dzen -- myPP h = defaultPP { ppCurrent = wrap "^bg(#444444)^p(2)^fg(#99ccff)^i(/home/thayer/.xmonad/dzen/corner.xbm)^fg(#ffffff)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId -- Trim the '[Int]:' from workspace tags , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()" , ppHidden = wrap "^fg(#ffffff)^p(2)^i(/home/thayer/.xmonad/dzen/corner.xbm)^fg()" "^p(2)^fg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId , ppHiddenNoWindows = id . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId , ppSep = " ^fg(#ffffff)^r(2x2)^fg() " , ppWsSep = " " , ppLayout = dzenColor "#ffffff" "" . (\x -> case x of "Tall" -> "tall ^i(/home/thayer/.xmonad/dzen/layout-tall.xbm)" "Mirror Tall" -> "mirror ^i(/home/thayer/.xmonad/dzen/layout-mtall.xbm)" "Full" -> "full ^i(/home/thayer/.xmonad/dzen/layout-full.xbm)" "Grid" -> "grid ^i(/home/thayer/.xmonad/dzen/layout-grid.xbm)" ) , ppTitle = dzenColor "white" "" . wrap "< " " >" , ppOutput = hPutStrLn h }