You are not logged in.

#1 2009-01-07 11:45:09

Zmyrgel
Member
From: Finland
Registered: 2006-09-30
Posts: 31

XMonad config not working as it should be [solved]

I just made the switch to xmonad from awesome but I have some difficulties on getting my xmonad.hs to work properly

Current issues are following:
- applications won't move to specified workspaces when I start them altough there are rules in xmonad.hs
- layout names are incorrect, should be "1:web", "2:term" ... as config states but layout names are printed as "web", "term" ....
- urgencyHook doesn't appear to work at all

Any insight on the above issues would be greatly appreciated.

And which of these is the prefered xmonad restart method:
-- broadcastMessage ReleaseResources >> restart "xmonad" True)
-- spawn "killall conky dzen2" >> restart "xmonad" True)

Here's my current config

-- {{{ Imports --

-- Standard
import XMonad
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
import Graphics.X11.Xlib
import IO (Handle, hPutStrLn) 

-- utils
import XMonad.Util.Run (spawnPipe)
import XMonad.Util.EZConfig

-- hooks
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.DynamicHooks


-- layouts
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile

-- actions
import XMonad.Actions.CycleWS
import XMonad.Actions.NoBorders
import qualified XMonad.Actions.FlexibleResize as Flex


-- }}}

-- {{{ Main --

main = do
    dzen <- spawnPipe myStatusBar
    dzentop <- spawnPipe myTopBar
    dzenbottom <- spawnPipe myBottomBar
    dynHooksRef <- initDynamicHooks
    xmonad $ urgencyHook' $ defaultConfig 
        { workspaces = workspaces'
        , modMask = modMask'
        , borderWidth = borderWidth'
        , normalBorderColor = normalBorderColor'
        , focusedBorderColor = focusedBorderColor'
        , terminal = terminal'
        , keys = keys'
        , mouseBindings = mouseBindings'
        , logHook = dynamicLogWithPP $ myDzenPP dzen 
        , layoutHook = layoutHook'
        , manageHook = manageHook' <+> manageDocks <+> dynamicMasterHook dynHooksRef
        , startupHook = setWMName "LG3D"
        }

-- }}}

-- {{{ Hooks --

-- manageHook
manageHook' = composeAll . concat $
    [ [className =? c --> doFloat | c <- myFloats]
    , [title =? t --> doFloat | t <- myOtherFloats]
    , [resource =? r --> doFloat | r <- myIgnores]
    , [className =? "Iceweasel"         --> doF (W.shift "1:web")]
    , [className =? "Firefox"           --> doF (W.shift "1:web")]
    , [className =? "Gran Paradiso"     --> doF (W.shift "1:web")]
    , [className =? "Gmpc"              --> doF (W.shift "6")]
    , [className =? "thunderbird-bin"   --> doF (W.shift "4:email")]
    , [className =? "thunderbird"       --> doF (W.shift "4:email")]
    , [className =? "claws-mail"        --> doF (W.shift "4:email")]
    , [className =? "pidgin"            --> doF (W.shift "3:im")]
    , [className =? "MPlayer"           --> doF (W.shift "5:video")]
    , [title =? "VLC media player"      --> doF (W.shift "5:video")]
    ]
    where
    myFloats = ["Gimp", "gimp", "MPlayer", "Xmessage"]
    myOtherFloats = ["Downloads", "Iceweasel Preferences", "Save As..."]
    myIgnores = []

-- layoutHook
layoutHook' = customLayout

-- urgencyHook
urgencyHook' = withUrgencyHook dzenUrgencyHook
    { args = ["-x", "0", "-y", "1184", "-h", "16", "-w", "1920", "-ta", "r", "-expand", "l", "-fg", "#0099ff", "-bg", "#0f0f0f", "-fn", "-xos4-terminus-medium-r-normal-*-14-*-*-*-c-*-iso10646-1"] }
 
-- }}}

-- {{{ Looks --

-- Statusbar options:
myStatusBar = "dzen2 -x '0' -y '0' -h '16' -w '1320' -ta 'l' -fg '#f0f0f0' -bg '#0f0f0f' -fn '-xos4-terminus-medium-r-normal-*-14-*-*-*-c-*-iso10646-1'"
myTopBar = "conky -c .conkytoprc | dzen2 -x '1320' -y '0' -h '16' -w '600' -ta 'r' -fg '#555555' -bg '#0f0f0f' -fn '-xos4-terminus-medium-r-normal-*-14-*-*-*-c-*-iso10646-1'"
myBottomBar = "conky -c .conkybottomrc | dzen2 -x '0' -y '1184' -h '16' -w '1920' -ta 'l' -fg '#555555' -bg '#0f0f0f' -fn '-xos4-terminus-medium-r-normal-*-14-*-*-*-c-*-iso10646-1'"

-- dynamicLog pretty printer for dzen:
myDzenPP h = defaultPP
    { ppCurrent = wrap "^fg(#0099ff)^bg(#333333)^p()^i(/home/zmyrgel/.dzen/corner.xbm)^fg(#ffffff)" "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
    , ppVisible = wrap "^fg(#ffffff)^bg(#333333)^p()^i(/home/zmyrgel/.dzen/corner.xbm)^fg(#ffffff)" "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
    , ppHidden = wrap "^i(/home/zmyrgel/.dzen/corner.xbm)" "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId -- don't use ^fg() here!!
    , ppHiddenNoWindows = wrap "^fg(#777777)^bg()^p()^i(/home/zmyrgel/.dzen/corner.xbm)" "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
    , ppUrgent = wrap "^fg(#0099ff)^bg()^p()" "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
    , ppSep = " "
    , ppWsSep = " "
    , ppTitle = dzenColor "#ffffff" "" . wrap "< " " >"
    , ppLayout = dzenColor "#ffffff" "" .
        (\x -> case x of
        "Hinted Tall" -> "^fg(#777777)^i(/home/zmyrgel/.dzen/layout-tall-right.xbm)"
        "Hinted Wide" -> "^fg(#777777)^i(/home/zmyrgel/.dzen/layout-mirror-bottom.xbm)"
        "Hinted Full" -> "^fg(#777777)^i(/home/zmyrgel/.dzen/layout-full.xbm)"
        "Hinted ResizableTall" -> "^fg(#777777)^i(/home/zmyrgel/.dzen/layout-tall-right.xbm)"
        "Hinted Mirror ResizableTall" -> "^fg(#777777)^i(/home/zmyrgel/.dzen/layout-mirror-bottom.xbm)"
        _ -> x
        )
    , ppOutput = hPutStrLn h
    }

-- }}}

-- {{{ borders

borderWidth' = 1
normalBorderColor'  = "#333333"
focusedBorderColor' = "#AFAF87"

-- }}}

-- {{{ workspaces

workspaces' = ["1:web", "2:term", "3:im", "4:email", "5:video"] ++ map show [6..9]

-- }}}

-- {{{ layouts

customLayout = avoidStruts $ smartBorders tiled ||| smartBorders (Mirror tiled)  ||| noBorders Full
  where
    tiled = ResizableTall 1 (2/100) (1/2) []

-- }}}

-- {{{ Terminal --

terminal' = "urxvtc"

-- }}}

-- {{{ Keys/Button bindings -- 

-- modmask
modMask' = mod4Mask

-- Mouse bindings
mouseBindings' (XConfig {XMonad.modMask = modMask}) = M.fromList $
    [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
    , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
    , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
    , ((modMask, button4), (\_ -> prevWS))
    , ((modMask, button5), (\_ -> nextWS))
    ]


-- keys
keys' c = mkKeymap c $
    
    -- XMonad stuff
    [ ("M-S-<Return>",  spawn $ XMonad.terminal c)
    , ("M-p",           spawn "exe=`dmenu_path | dmenu -nb 'black' -nf 'white' -sb 'grey' -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -b` && eval \"exec $exe\"")
    , ("M-S-p",         spawn "gmrun")
    , ("M-S-c",         kill)
    , ("M-S-q",         io (exitWith ExitSuccess)) -- Quit XMonad
    , ("M-q",           broadcastMessage ReleaseResources >> restart "xmonad" True) -- Restart xmonad
    -- spawn "killall conky dzen2" >> restart "xmonad" True)
    
    -- applications
    , ("M-<SysReq>",    spawn "scrot screen_%Y-%m-%d.png -d 1")
    , ("M-a m",         spawn "claws-mail")
    , ("M-a d",         spawn "date +'%Y-%m-%d %H:%M' | osd_cat -p bottom -A center -s 2 -c '#a10a30' -f '-xos4-terminus-medium-r-normal-*-140-*-*-*-c-*-iso10646-1'")

    -- layouts 
    , ("M-<Space>",       sendMessage NextLayout) 
    , ("M-S-<Space>",     setLayout $ XMonad.layoutHook c)
    , ("M-b",           sendMessage ToggleStruts)

    -- floating layer 
    , ("M-o",           withFocused $ windows . W.sink) 
    
    -- refresh
    , ("M-r",           refresh) 

    -- focus
    , ("M-<Tab>",       windows W.focusDown) 
    , ("M-t",           windows W.focusDown) 
    , ("M-n",           windows W.focusUp) 
    , ("M-m",           windows W.focusMaster) 
    , ("M-u",           focusUrgent)
    
    -- swap 
    , ("M-<Return>",    windows W.swapMaster)
    , ("M-S-t",         windows W.swapDown) 
    , ("M-S-n",         windows W.swapUp) 

    -- increase or decrease number of windows in master area
    , ("M-,",           sendMessage (IncMasterN 1)) 
    , ("M-.",           sendMessage (IncMasterN (-1))) 

    -- resizing
    , ("M-h",           sendMessage Shrink) 
    , ("M-s",           sendMessage Expand) 
    , ("M-S-h",         sendMessage MirrorShrink) 
    , ("M-S-s",         sendMessage MirrorExpand)
    
    -- misc client stuff 
    , ("M-S-b",         withFocused toggleBorder)

    -- mpd controls
    , ("M-C-<L>",       spawn "mpc --no-status prev")
    , ("M-C-<R>",       spawn "mpc --no-status next")
    , ("M-C-<U>",       spawn "mpc --no-status toggle")
    
    -- workspace
    , ("M-<L>",         prevWS)
    , ("M-<R>",         nextWS)
    
    ]

    ++
    -- mod-[1..9], Switch to workspace N
    -- mod-shift-[1..9], Move client to workspace N
    [(m ++ k, windows $ f w)
         | (w, k) <- zip (XMonad.workspaces c) (map show [1..9])
         , (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]]
-- }}}

Edit: Fixed the rules a bit and things started to work as they should.

Last edited by Zmyrgel (2009-01-09 19:51:37)

Offline

Board footer

Powered by FluxBB